First, you must restrict to $\,a,b\in \Bbb N\,$ else it is false, e.g. $\, (-1)(-4) = 2^2$ but $\,-4\,$ is not a square.
Theorem $\ a,b\,$ coprime, $\, ab=n^2\Rightarrow\, a,b\,$ are squares, if $\,a,b,n\in \Bbb N.$
Proof $\ $ By induction on $\,n.\,$ Clear if $\,n=1.\,$ Else $\,n > 1,\,$ so some prime $\,p\mid n\,$ so $\,p^2\mid n^2\!= ab,\,$ $\rm\color{#c00}{thus}$ $\,p^2\mid a\,$ or $\,p^2\mid b,\,$ by $\,a,b\,$ coprime. Wlog $\,p^2\mid b,\,$ thus $\,ab=n^2\Rightarrow\ a(b/p^2) = (n/p)^2$ by canceling $\,p^2.\,$ Since $\,n/p < n,\,$ by induction there are $\,c,d\in\Bbb N$ such that $\, a = c^2,\ b/p^2 = d^2,\,$ so $\,b = (pd)^2.\ $ QED
Remark $\ $ The $\rm\color{#c00}{key\ property}$ used is that $\,p^2\mid ab\,\Rightarrow\,p^2\mid a\,$ or $\,p^2\mid b,\:$ if $\,a,b\,$ are coprime. This is an immediate consequence of the Fundamental Theorem of Arithmetic (existence and uniqueness of prime factorizations), or equivalent well-known properties, e.g. one can iterate Euclid's Lemma $\ p\mid ab\,\Rightarrow\, p\mid a\,$ or $\,p\mid b.\,$ The same holds true for $\,k$'th powers of primes, so the proof generalizes from squares to $\,k$'th powers and, further, from $\,\Bbb Z\,$ to any UFD (e.g. $\,F[x],\,$ a polynomial ring over a field). In the general case one must allow for unit factors, i.e. the result is that $\,a = uc^2,\ b = u^{-1} d^2$ for some $\,c,d\,$ and some unit (invertible) $\,u.\,$ We eliminated $\, u = \pm1 \in \Bbb Z\,$ by requiring $\,a,b > 0.$
$a=p_1^{\alpha_1}\cdots p_n^{\alpha_n}$
And
$b=q_1^{\beta_1}\cdots q_m^{\beta_m}$
– Fardad Pouran Jun 07 '14 at 15:48