Every set of $n$ generators is a basis for $A^{n}$ This is problem $15$ from Chapter $3$ of Atiyah and Macdonald's book.

Let $A$ be a ring let $F$ be the $A$-module $A^{n}$. Show that every set of $n$ generators is a basis of $F$. 

Here's the hint:
Let $x_{1},...,x_{n}$ be a set of generators of $F$ and let $e_{1},...,e_{n}$ be the canonical basis of $F$. Let $\phi: \rightarrow F$ be defined by $\phi(e_{i})=x_{i}$. Then $\phi$ is surjective and we may assume $A$ is local. Let $N=\ker(\phi)$ and let $k=A/\mathfrak{m}$ be the residue field of $A$. Since $F$ is a flat $A$-module then the exact sequence:
$$0 \rightarrow N \rightarrow F \rightarrow F \rightarrow 0$$ 
induces an exact sequence
$$0 \rightarrow k \otimes N \rightarrow k \otimes F \rightarrow k \otimes F \rightarrow 0.$$
First question: we actually need to assume $A^{n}$ is local no? because $F=A^{n}$ but if $A^{n}$ is local then so is $A$ right? because every maximal ideal $M_{i}$ of $A^{n}$ is of the form $A_{1} \times A_{2} \times... M_{i} \ ... \times A_{n}$. And if $A$ is local then $A^{n}$ is local so $A$ is local iff $A^{n}$ is local. Is this the reasoning behind the hint?
Second question: The part I don't understand is why when tensoring with $k$ the sequence remains exact? we know that $F$ is flat because it is free so tensoring any exact sequence with $F$ remains exact, but why tensoring with $k$ also remains exact? it seems that we are assuming $k$ is a flat $A$-module, but why is this? 
 A: At the OP's request, I am converting some of my comments above into an answer:
Firstly, $A^n$ is never being considered as a ring, just an $A$-module, so it doesn't make sense to say that $A^n$ is local. (Locality is a property of rings, not modules.) As a side point, if $n>1$ and $A$ is non-zero, then $A^n$ is never local, so it is good that locality of $A^n$ is not required!  
(To prove this last point: let me take $n=2$ for concreteness. If $A$ is non-zero, it contains a maximal ideal $m$. Then $A\times m$ and $m\times A$ are both maximal ideals of $A^2$, so $A^2$ cannot be local.  A differently phrased, more geometric, argument is that Spec $A^2$ is the disjoint union of Spec $A$ with itself, hence is disconnected, while Spec of a local ring is always connected. The two arguments are closely related, in fact.)
Secondly, $k$ will not be flat as an $A$-module unless $A=k$ (see here), so, while it is true that one would have exactness after tensoring with $k$ were flat as an $A$-module, that flatness will almost never hold. The point is that if 
$0 \to M^′\to M \to M^{′′}\to 0$  is an exact sequence of $A$-modules with $M^{′′}$ flat and $N$ is any $A$-module, then $0\to M^′\otimes N \to M\otimes N\to M^{′′}\otimes N \to 0$ is again exact. There are various ways to see this: Steve D notes one (an argument with Tor) in his comment above. As Olivier Begassat notes, in your case M′′ is not just flat, but free, so 
in fact the original exact sequence splits, which makes it obvious that it stays exact after tensoring. (Nevertheless, the more general statement with flat modules if often very useful.)

Another remark: there are other ways to prove this (as Pete Clark notes in
his answer) besides following the outline of Atiyah and Macdonald.  Pete
Clark has noted one (which in fact proves a more general statement).
Another is to regard $\phi$ as an $n \times n$-matrix, note that since it is
a surjection it remains so after reducing modulo $\mathfrak m$ for every maximal ideal of $A$, hence is invertible modulo every $\mathfrak m$, thus has
unit determinant modulo every $\mathfrak m$, thus has unit determinant, and thus
is itself invertible.  (Note that arguing with determinants is in some sense
a way of avoiding Nakayama's lemma by using the ingredients in its proof.)
A: For a (let's say commutative) ring $R$, a left $R$-module is Hopfian if every surjective $R$-module map from $M$ to $M$ is an isomorphism.  The exercise in Atiyah-Macdonald can thus be restated as: every finitely generated free module over a commutative ring is Hopfian.
In fact a stronger result is true: every finitely generated module over a commutative ring is Hopfian.  The proof is a quick -- but somewhat tricky -- application of Nakayama's Lemma.  See for instance $\S 3.8.2$ of my commutative algebra notes.  The argument given there is taken from (page 9!) of Matsumura's Commutative Ring Theory.  (The proof does not require homological algebra although a few of the exercises in Atiyah-Macdonald do.)
Note that an easy example of a non-Hopfian module is the direct sum of countably many copies of any nonzero $R$-module $M$, so finite generation is an absolutely necessary hypothesis.
Let me address a couple of questions you ask later in your post.
1: $A^n$ is not a local ring when $n > 1$ (and $A \neq 0$, of course).  Your description of the maximal ideals makes reference to the $i$th component, so by varying $i$ you get more than one maximal ideal.
2: No, if $\mathfrak{m}$ is a nonzero maximal ideal of $R$, then $k = R/\mathfrak{m}$ need not be a flat $R$-module.  For instance, when $R$ is a domain, every flat $R$-module is torsionfree hence faithful, but $k$ has a nonzero annihilator $\mathfrak{m}$.  However it is still true that after tensoring with $k$ the sequence is exact, for instance by an argument involving $\operatorname{Tor}$ as noted in the comments, or as Matt notes, since the freeness of the last term in the original short exact sequence means the sequence splits, and tensoring a split exact sequence results in another split exact sequence.
A: This is not another answer, but a long comment directed at Pierre-Yves Gaillard!
@Pierre-Yves Gaillard It ressembles it, but it manages to not use Nakayama's lemma. You can find it as Théorème 5.3.3 (p.51) in http://hlombardi.free.fr/EnseignementWeb/Modules-M1.pdf.
Here's the proof. Take $M$ a finitely generated $A$ module, say generated by $m_1,\dots,m_r$, and $\varphi\in\mathrm{End}_A(M)$ surjective. You define (a priori non unique) coefficients $(a^i_j)\in M_r(A)$ by setting $m_j=\varphi(\sum a^i_j\cdot m_i)$; next, this is where it converges with Pete's proof, you define $B$ to be the $A$-subalgebra of $\mathrm{End}_A(M)$ generated by $\varphi$ (so it coincides with the image of the canonical homomorphism of $A$ algebras $A[X]\to\mathrm{End}_A(M)$ sending $X$ to $\varphi$). $B$ is a ring, and $M$ is naturally a $B$ module, so you get a $M_r(B)$ module structure on $M^r$.
Consider the following matrix $$P=\left( \begin{array}{cccc} 
a^1_1\varphi & a^1_2\varphi & \ldots & a^1_r\varphi \\
a^2_1\varphi & a^2_2\varphi & \ldots & a^2_r\varphi \\
\vdots & \vdots & \ddots & \vdots\\
a^r_1\varphi & a^r_2\varphi & \ldots & a^r_r\varphi \\
\end{array}\right) \in M_r(B).$$
By definition of the various coefficients, you have 
$$(\mathrm{I}_r-P)\cdot\left(\begin{array}{c}
m_1 \\
m_2\\
\vdots \\
m_r
\end{array}\right) = \left(\begin{array}{c}
0 \\
0\\
\vdots \\
0
\end{array}\right).$$
Next, you apply the comatrix identity (inside $M_r(B)$, which works, since $B$ is a commutative ring) to $\mathrm{I}_r-P$ to get $$(\mathrm{I}_r-P)\times \mathrm{Com}(\mathrm{I}_r-P)^{\mathrm{T}}=\mathrm{Com}(\mathrm{I}_r-P)^{\mathrm{T}}\times (\mathrm{I}_r-P)= \det(\mathrm{I}_r-P)\cdot\mathrm{I}_r$$, with $\det(\mathrm{I}_r-P)=\mathrm{id}_M - \varphi\times p(\varphi)=\mathrm{id}_M - p(\varphi)\times\varphi$ for some $p\in A[X]~($by definition, $1_B=\mathrm{id}_M=1_{\mathrm{End}_A(M)})$. Reapply the vector $\left(\begin{array}{c}
m_1 \\
m_2\\
\vdots \\
m_r
\end{array}\right)$ to it, remember that the $m_i$ span $M$, and you'll end up with the fact that $\varphi$ is an isomorphism of $M$, with inverse $p(\varphi)$. If your name is any indication, you will be able to read this in the notes I linked you to.

EDIT I guess the ``canonical proof'' goes as follows: make $M$ into an $A[T]$-module by setting $P\cdot m := P(\varphi)\big(m\big)$. Surjectivity of $\varphi$ means that $(T)\cdot M=M$. The the Cayley-Hamilton implies that there exists $P\in k[T]$ with $P\equiv 1\mod(T)$ and $P\cdot M=0$. Writing $P=1-TQ$ with $Q\in k[T]$, we have
$$\forall m\in M, m=\varphi\circ Q(\varphi)\big(m\big)$$
i.e.
$$\varphi\circ Q(\varphi)=\mathrm{id}_M.$$
A: This is a comment about Pete's answer.
Pete writes:

In fact a stronger result is true: every finitely generated module over a commutative ring is Hopfian.  The proof is a quick -- but somewhat tricky -- application of Nakayama's Lemma.  See for instance $\S 3.8.2$ of my commutative algebra notes. The argument given there is taken from (page 9!) of Matsumura's Commutative Ring Theory.

I'll try to rephrase Matsumura's argument in a slightly different way.

Theorem. Let $A$ be a commutative ring and $\psi$ a surjective endomorphism of a finitely generated $A$-module $M$. Then $\psi$ is invertible.

We'll use the

Lemma. Let $B$ be a commutative ring, $\mathfrak b\subset B$ an ideal, $M$ a finitely generated $B$-module, and $\phi$ an endomorphism of $M$ such that $\phi M\subset\mathfrak bM$. Then $\phi$ is in the radical of the ideal $\mathfrak b[\phi]$ of $B[\phi]$:
$$
\phi\in r(\mathfrak b[\phi])\subset B[\phi].
$$

The Lemma implies the Theorem. Applying the Lemma to the ring $B:=A[\psi]$, to the ideal $\mathfrak b:=(\psi)\subset B$, to the module $M$, and to the endomorphism  $$
\phi:=\text{id}_M=1\in B=A[\psi],
$$
we see that $1$ is in the radical of $(\psi)\subset B$. This implies indeed that $\psi$ is invertible.
Proof of the Lemma. Let $(x_j)$ be a finite system generating $M$. Each $x_j$ can be written as
$$
x_j=\phi\  \sum_k\ a_{jk}\ x_k
$$
for some $a_{jk}$ in $\mathfrak b$. In other words we have
$$
\sum_k\ (\delta_{jk}-a_{jk}\phi\ )\ x_k=0
$$
(where $\delta$ is Kronecker's delta), i.e. the elements
$$
b_{jk}:=\delta_{jk}-a_{jk}\phi\in B[\phi]
$$
satisfy
$$
\sum_k\ b_{jk}\ x_k=0.
$$
If $(c_{ij})$ is the adjugate of the matrix $(b_{jk})$, we get
$$
\sum_j\ c_{ij}\ b_{jk}=\delta_{ik}\ \Delta,\quad\Delta:=\det(b_{jk})\in B[\phi].
$$
Let's compute
$$
y_i:=\sum_{j,k}\ c_{ij}\ b_{jk}\ x_k\in M
$$
in two ways. On the one hand we have
$$
y_i=\sum_j\ c_{ij}\ \sum_k\ b_{jk}\ x_k=0.
$$
On the other hand we have
$$
y_i=\sum_k\ \left(\sum_j\ c_{ij}\ b_{jk}\right)x_k=\sum_k\ \delta_{ik}\ \Delta x_k=\Delta x_i.
$$
This implies successively that $\Delta x_i=0$ for all $i$, that $\Delta x=0$ for all $x$ in $M$, and that $\phi$ is in the radical of the ideal $\mathfrak b[\phi]$ of $B[\phi]$.
