We have the equation in $x$: $$x^2 = 2^x$$
We know that, by logic, if we equate the bases and the powers separately, we get $x=2$ in both the cases and thus we conclude that $2$ is the root of the equation.
But what if we don't apply that logic. Is their a mathematical way we can get the same result? Using mathematical steps instead of intuition and logic?
Short answer: no, not probably in the way you'd like. This is a transcendental equation and in general these must be solved graphically if you can't find solutions by inspection as in this case. (Even in this case, you haven't found all of the solutions... there are complex solutions).
However, if you wish, this particular transcendental equation has solutions in terms of the lambert W function $w(z)$, which is defined by the equation $z = w(z) e^{w(z)}$ (which itself cannot be solved by doing algebra).