[proofplan]
We compare the prime exponents in the factorizations of $a$, $b$, and $ab$. Coprimality implies that no prime divisor occurs in both $a$ and $b$, so each exponent in $ab$ is inherited unchanged from exactly one factor. Since $ab$ is a square, all prime exponents in $ab$ are even; hence all prime exponents in $a$ and $b$ are even, which reconstructs $a$ and $b$ as squares.
[/proofplan]
[step:Write prime factorizations for $a$, $b$, and the square root of $ab$]
By unique prime factorization (citing a result not yet in the wiki: [Fundamental Theorem of Arithmetic](/theorems/730)), there exist pairwise distinct primes $p_1,\dots,p_m$, positive integers $\alpha_1,\dots,\alpha_m \in \mathbb{N}$, pairwise distinct primes $q_1,\dots,q_n$, positive integers $\beta_1,\dots,\beta_n \in \mathbb{N}$, and a positive integer $c \in \mathbb{N}$ such that
\begin{align*}
a &= \prod_{i=1}^{m} p_i^{\alpha_i}, \\
b &= \prod_{j=1}^{n} q_j^{\beta_j}, \\
ab &= c^2.
\end{align*}
If $a=1$, the product over $i$ is empty, and if $b=1$, the product over $j$ is empty. In those cases the corresponding integer is already a square, so the same argument below applies with an empty list of prime exponents.
[/step]
[step:Use coprimality to separate the prime divisors of $a$ and $b$]
We claim that no prime appearing among $p_1,\dots,p_m$ appears among $q_1,\dots,q_n$. Suppose, for contradiction, that $p_i=q_j$ for some indices $i \in \{1,\dots,m\}$ and $j \in \{1,\dots,n\}$. Then $p_i$ divides $a$ and $p_i$ divides $b$, so $p_i$ divides $\gcd(a,b)$. This contradicts $\gcd(a,b)=1$, since $p_i$ is a prime and therefore $p_i>1$. Hence the two prime lists are disjoint.
[guided]
The condition $\gcd(a,b)=1$ is exactly the condition that $a$ and $b$ have no common prime divisor. To make this precise, suppose a prime $p_i$ from the factorization of $a$ were also a prime $q_j$ from the factorization of $b$. Then $p_i \mid a$ because it occurs in the prime factorization of $a$, and $p_i \mid b$ because $p_i=q_j$ occurs in the prime factorization of $b$. Therefore $p_i$ is a common divisor of $a$ and $b$, so $p_i \mid \gcd(a,b)$. Since $\gcd(a,b)=1$, this would force $p_i \mid 1$, impossible because $p_i>1$. Thus the prime divisors of $a$ and $b$ are disjoint.
[/guided]
[/step]
[step:Show every prime exponent in $a$ and $b$ is even]
Because the prime lists for $a$ and $b$ are disjoint, the prime factorization of $ab$ is
\begin{align*}
ab &= \left(\prod_{i=1}^{m} p_i^{\alpha_i}\right)
\left(\prod_{j=1}^{n} q_j^{\beta_j}\right),
\end{align*}
with no cancellation or merging of equal prime factors between the two products.
Since $ab=c^2$, every exponent in the prime factorization of $ab$ is even. Therefore each $\alpha_i$ is even, and each $\beta_j$ is even. Thus there exist nonnegative integers $\gamma_1,\dots,\gamma_m$ and $\delta_1,\dots,\delta_n$ such that
\begin{align*}
\alpha_i &= 2\gamma_i \quad \text{for each } i \in \{1,\dots,m\}, \\
\beta_j &= 2\delta_j \quad \text{for each } j \in \{1,\dots,n\}.
\end{align*}
[guided]
A square has even prime exponents. Indeed, if
\begin{align*}
c &= \prod_{\ell=1}^{k} r_\ell^{\theta_\ell}
\end{align*}
is the prime factorization of $c$, then
\begin{align*}
c^2 &= \prod_{\ell=1}^{k} r_\ell^{2\theta_\ell},
\end{align*}
so every prime exponent in $c^2$ is even.
Now apply this to $ab=c^2$. Because $a$ and $b$ have no common prime divisor, multiplying their factorizations does not combine equal primes from the two sides. Therefore the exponent of $p_i$ in $ab$ is exactly $\alpha_i$, and the exponent of $q_j$ in $ab$ is exactly $\beta_j$. Since $ab$ is the square $c^2$, all these exponents must be even. Hence there are nonnegative integers $\gamma_i$ and $\delta_j$ with
\begin{align*}
\alpha_i &= 2\gamma_i, \\
\beta_j &= 2\delta_j.
\end{align*}
[/guided]
[/step]
[step:Reconstruct $a$ and $b$ as squares]
Define integers $r,s \in \mathbb{N}$ by
\begin{align*}
r &= \prod_{i=1}^{m} p_i^{\gamma_i}, \\
s &= \prod_{j=1}^{n} q_j^{\delta_j},
\end{align*}
where an empty product is interpreted as $1$. Then
\begin{align*}
r^2 &= \left(\prod_{i=1}^{m} p_i^{\gamma_i}\right)^2
= \prod_{i=1}^{m} p_i^{2\gamma_i}
= \prod_{i=1}^{m} p_i^{\alpha_i}
= a,
\end{align*}
and similarly
\begin{align*}
s^2 &= \left(\prod_{j=1}^{n} q_j^{\delta_j}\right)^2
= \prod_{j=1}^{n} q_j^{2\delta_j}
= \prod_{j=1}^{n} q_j^{\beta_j}
= b.
\end{align*}
Therefore $a$ and $b$ are both squares in $\mathbb{N}$.
[/step]