The proof as given in " David M. Burton " is as follows:
Suppose that $a^n \equiv a \pmod n$ for every integer a, but $k^2\mid n$ for some $k > 1.$ If we let $a = k,$ then $k^{n} \equiv k \pmod n.$ Because $k^2\mid n$, this last congruence holds modulo $k^2$; that is $ k \equiv k^{n} \equiv 0 \pmod {k^2}$, whence $k^2\mid k$, which is impossible. Thus, $n$ must be square-free.
But I do not understand this statement :
"this last congruence holds modulo $k^2$; that is $ k \equiv k^{n} \equiv 0\pmod {k^2}$"
Could anyone explain it for me please? why this last congruence holds modulo $k^2$ ? and why this leads to that $ k^{n} \equiv 0$?