We just use the Bézout's identity to solve this problem.

$\textbf{Lemma 1}$ $\gcd( x, y ) = 1 \Leftrightarrow \gcd( x^2, y^2 ) = 1$

Proof. On the one hand, if $\gcd( x^2, y^2 ) = 1$, $\exists s,t \in \mathbb{Z}$ such that $sx^2 + t y^2 =1$. Let $u = sx$ and $v =ty$, then $ux + vy =1$. Thus $\gcd( x, y ) = 1$.

One the other hand, if $\gcd( x, y ) = 1$, $\exists u,v \in \mathbb{Z}$ such that $ux + vy =1$.
$$
\begin{aligned}
1 &= ux + vy \\
&= (ux + vy)^2 \\
&= u^2x^2 + 2uvxy +v^2y^2 \\
&= u^2x^2 + 2uvxy(ux + vy) +v^2y^2 \\
&= (1+2vy)u^2x^2 + (1 + 2ux)v^2y^2 \\
\end{aligned}
$$
Let $s = (1 + 2vy)u^2$ and $t = (1 + 2ux)v^2$, then $sx^2 + ty^2 = 1$, Thus $\gcd( x^2, y^2 ) = 1$.

$\Box$

$\textbf{Theorem 1}$ $a|b \Leftrightarrow a^2|b^2$

Proof. Let $\gcd (a , b) =d$. Then $a = xd$, $b = yd$ and $\gcd( x, y ) = 1$. Since $\gcd (x, y) =1 \Leftrightarrow \gcd (x^2, y^2) =1$ by lemma 1,
$$
a^2 | b^2
\Leftrightarrow x^{2} | y^{2}
\Leftrightarrow x^2 = 1
\Leftrightarrow x = \pm 1
\Leftrightarrow a = \pm d
\Leftrightarrow a|b
$$

$\Box$