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?
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.)