The problem comes from writing simple "sqrt" functions rather than "+/-sqrt". IOW, whenever you take the square root, you have to take into consideration that there are two square roots of any complex number, which differ by a factor of -1. Deciding which roots to take to maintain an equality often requires working through exactly the kind of computation you have shown.
I would have looked at the second line in your "proof" and decide which sign each sqrt should have. To do that I would go through pretty much the proof you have, and when I got "-1=1", I would say, "Oh - that's not it - I guess the two sqrts have to have opposite signs to maintain the equality."
I know that looks circular, but it's really how you decide which root to take. It might be clearer with pure real numbers:
(-2)^2 = (2)^2
sqrt((-2)^2) = sqrt((2)^2)
-2 = 2
oops ... should have had a minus sign in line 2!