What I have done is this:
$a\equiv b \pmod{2n}$,
$a=b+c\times2n$, for some $c$,
$a^2=b^2+2b\times c\times2n+c^2\times2^2n^2$,
$a^2-b^2=(b\times c+c^2n)\times4n$, then
$a^2\equiv b^2\pmod{2^2n}$.
I think that this is right: what I DON’T understand is how to generalize this to:
$a\equiv b\pmod{kn}\Rightarrow a^k\equiv b^k \pmod{k^2n}$.
Please give me a hint.
Since $a\equiv b\pmod{kn}$, we have $$a=b+ckn$$ for some integer $c$. Now taking the $k$th power on both sides, we have $$a^k=(b+ckn)^k.$$ By the binomial theorem, the right hand side is given by $$(b+ckn)^k=b^k+\sum_{i=1}^k{k\choose i}(ckn)^ib^{k-i}.$$ For $i\geq 2$, it is clear that ${k\choose i}(ckn)^ib^{k-i}$ is divisble by $k^2n$. On the other hand, for $i=1$, we have ${k\choose i}(ckn)^ib^{k-i}=ck^2nb^{k-1}$, which is also divisble by $k^2n$. Therefore, by the above equality, we have $$(b+ckn)^k=b^k+k^2nN$$ for some integer $N$. Combining all these, we have $$a^k=(b+ckn)^k=b^k+k^2nN,$$ that is $$a^k\equiv b^k \pmod{k^2n}.$$