Some algebraic steps are reversible, meaning that the equation before the step is true if and only if the equation after the step is true. For example, adding a constant to both sides of an equation is reversible: $x=y-7$ is true if and only if $x+7=y$ is true.
Some algebraic steps are valid but not reversible, meaning that if the equation before the step is true then the equation after the step is true, but not necessarily vice versa. For example, applying cosine to both sides of an equation is a valid but non-reversible step: if $x=y$ then $\cos x=\cos y$, but if $\cos x=\cos y$ then it's not necessarily the case that $x=y$ (take $x=0$ and $y=2\pi$ for example). Applying a non-reversible algebraic step is the most common way that "false solutions" arise in algebra.
Squaring both sides of an equation is a non-reversible algebraic step. It's valid (if $x=y$ then $x^2=y^2$) but its reverse is not always valid (for example, $(-3)^2=3^2$ but $-3\ne3$). Therefore, when you go from the first line to the second line by (multiplying and) squaring both sides, there is the potential for additional solutions to arise (that is, numbers $x$ that are solutions to the second line but not solutions to the first line). That is in fact what you observed.
Non-reversible steps are still very useful, as they limit the set of possible solutions; but using them requires us to check the list of possible solutions to see whether they are actual solutions to the original equation. There might be other ways to solve this original equation using only reversible steps, but I think it's better to get used to the fact that non-reversible steps are very useful and just complete the algebraic process of checking the potential solutions found.
(And, as Vinyl_cape_jawa notes, when you say "the tangent line is equal to $1$", you should say "the slope of the tangent line is equal to $1$". Mathematics is such a precise language that it's a good habit to develop to be very precise when speaking about it.)