Let's add the hypothesis that $x>0$ to the problem, so that it's clear your derivations are correct.
Pay attention to what you've proven:
- If $x^{x^{\cdot^\cdot}} = 2$, then $x = \sqrt{2}$
- If $x^{x^{\cdot^\cdot}} = 4$, then $x = \sqrt{2}$
This is very different from
- If $x = \sqrt{2}$, then $x^{x^{\cdot^\cdot}} = 2$
- If $x = \sqrt{2}$, then $x^{x^{\cdot^\cdot}} = 4$
Your argument that $2=4$ requires this latter pair of statements, but you haven't proven either of them; instead, what you've proven are the first pair of statements!
It's easy to get in the habit of forgetting about the direction you've argued a problem, and in many situations, arguments are reversible, making it hard to see why direction matters. But this is an example of the dangers of getting things wrong!
Incidentally, if $x = \sqrt{2}$ then $x^{x^{\cdot^\cdot}} = 2$ is correct, if we assume the usual meaning of infinite power towers as a limit of finite ones. If you're familiar with limits of sequences, then you can use an inductive proof to show that the sequence
$$ a_0 = \sqrt{2} \qquad \qquad a_{n+1} = \sqrt{2}^{a_n} $$
is strictly increasing and bounded above by $2$, and so the limit converges. And if $L$ is the limit, then because exponentiation is continuous, we can take the limit of the recursive relation to see that
$$L = \sqrt{2}^L$$
letting you complete the proof.