First, suppose we know that $$x^2 = y^2.$$ From this we can conclude $$x = \pm y.\tag{$\star$}$$
If we know that both $x$ and $y$ are positive, we can do a little better: $$x=y.$$
(This is the crucial step. Make sure you understand it before going on.)
Now, suppose we want to show that $\sqrt a\sqrt b = \sqrt{ab}$. The squares of $\sqrt a\sqrt b$ and $\sqrt{ab}$ are equal (both squares are $ab$), so by $(\star)$ we know that $$\sqrt a\sqrt b = \pm\sqrt{ab}.$$
And if we knew that both sides were positive, we could do better: $$\sqrt a \sqrt b = \sqrt{ab}.$$
If $a$ and $b$ are positive, then we do know that both sides are positive, because when $x$ is positive $\sqrt x$ is defined to be a positive number, specifically the unique positive number whose square is $x$.
But if $x$ is negative (or complex), the meaning of $\sqrt x$ changes subtly, and is harder to pin down. Every number (except 0) has not one but two
square roots, and when $x$ is negative we can't pick out the one we want by saying we want the positive one, because neither one is positive.
If $a$ or $b$ might be negative, then we can still say $$\sqrt a \sqrt b = \pm \sqrt{ab}$$ but we can't take that extra step to get rid of the $\pm$ sign.
You might ask why we couldn't find some way to extend the notion of “positive square root” when $x$ is negative or complex. Say for example we agree to always take the one whose imaginary part is positive, so that $\sqrt{-1}$ always means $i$ and never $-i$. We can do this, but it still doesn't get us what we want, because now we lose the property that the product of two positive numbers is positive! For example, we've just agreed to say that $i$ is positive, but the product $i\cdot i$ of two positive numbers is $-1$ which is not positive. So we still can't conclude that $\sqrt a\sqrt b$ and $\sqrt {ab}$ are both positive, and therefore we can't conclude that they are equal.
$$1 = \sqrt{1} = \sqrt{-1\cdot-1} = \sqrt{-1}\cdot\sqrt{-1} = -1$$
The restriction is necessary.
– DanielV Nov 13 '16 at 05:35