Proof. We will prove the contrapositive. Suppose $d\nmid a$. By the division algorithm, $a = qd + r$ for some $q\geq 0 $ and $0<r<\lvert d \rvert$. Then, $a^{2} = (qd + r)^{2} = q^{2}d^{2} + 2qdr + r^{2} = d^{2}(q^{2} + \frac{2qr}{d}) + r^{2}$. Since $r < \lvert d \rvert$ ,$r^{2}< d^{2}$. Thus, there is a nonzero remainder, so $d^{2}\nmid a^{2}$. Hence if $d^{2}\mid a^{2}$, $d\mid a$.
$\square$