You've been lied to about how solving equations works.
Mathematics it taught as a series of patterns and techniques; that is useful for someone doing computation by hand, but it what you are taught is basically full of lies.
When you take $$\sqrt{x} = 2$$ and you "solve" it by tasquaring both sides $$x=4$$, what you are actually doing is claiming that the two equations are equivalent. But many of the steps you take don't actually involve equivalent equations; they are equivalent almost always, or the first implies the second, or the second implies the first.
Here, the same process starting with $-\sqrt{x} = 2$ where you square both sides to $x=4$ gives a spurious solution; the problem is $a=b$ implies $\sqrt{a}=\sqrt{b}$ but not the other way around.
Doing such transformations can lead you to an answer, but can also include extra "solutions" which are not valid; in fact, you might end up with none of the solutions being valid (if the original equation had no answers, for example).
In simple cases, this is often when you implicitly multiply by 0 (clearing denominators, or some trig identities), but not always.
To do mathematics more carefully, you need to understand which statement implies the other and in which cases this implication is valid (and when it is invalid).
If your goal is finding a solution, you want backwards implication - if you start with equation A, you want the next step B to IMPLY A. Then any solution you find will solve A.
If your goal is showing there is no solution, then you want forward implication. If you start with A, the next step B should be IMPLIED by A. Then if you come up with a contradiction you know there is no solution to A.
If your goal is to find every solution, then you want bi-directional implication - equivalence - in each step.
If you have limited connection - the connection isn't valid for certain values - you have to "fork" your solution (do the rest of it twice) and check that case separately. Sometimes that is easy; you can just inspect that case. In your case, you aren't doing that, and those "forks" are showing up in your simplified equation and you can't tell they are invalid solutions.
When taught to manipulate equations in practice people skip this detail, or don't focus on it very heavily, or fix it in a post-processing pass where they say "and then check your solutions to make sure they work". This is a practical way to handle the problem, but it means you'll be doing unsound work in the middle and might not even realize it.
You are seeing the effects of that unsound work. Now quite often, especially with toy problems you get for education purposes, the unsoundness is just a quirk.
sqrt
function works in programming languages. Cauchy played a big role in establishing this convention in the 19th century but you're correct that others used the symbol in a multivalued way: for more on the history of the convention see hsm.stackexchange.com/questions/18440/… $\endgroup$