How would we solve $x^2 = 2^x$ mathematically rather than logically? 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?
 A: Your logic can only cover part of the solutions, but may not find out all of them.
If you are seeking real solutions only, 
Take logarithm at both side
$$x^2=2^x$$
$$2\ln x=x\ln 2$$
$$\frac{\ln x}x=\frac{\ln2}2$$
Now consider the function
$$f(x)=\frac{\ln x}x$$
$$f'(x)=\frac{1-\ln x}{x^2}$$
$f(x)$ is increasing in $(0,e)$ and decreasing in $(e,\infty)$. 
Thus $f(x)=\frac{\ln2}2$ has exactly one solution at each of the region $(0,e)$ and $(e,\infty)$. 
With observation we know the only positive real solutions are $x=2$ and $x=4$.

Edit:
As the comment and other answers suggested, there is also a negative solution given in terms of 
the Lambert W function, which is defined as the inverse function of $f(z)=ze^z$.
We may use the identity 
$$z=W(z)e^{W(z)}$$
Using this approach by @Aaron Maroja 
$$ x=-\frac2{\ln2}W(\frac{\ln2} 2)\approx-0.766$$
A: 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).
A: $x^y=y^x$ : $x=y$ => o.k. $\enspace$(trivial like $x=x$)  
$x>y$ => relation by parametrisation $x=(1+\frac{1}{t})^{t+1}$ and $y=(1+\frac{1}{t})^t$ with $t>0$.
For $y=2$ in the first case we have $x=2$ and in the second case we get $x=4$ using $t=1$ . 
If $x<0$ and $y=2$ you can change to $x^2=(\frac{1}{2})^x$ with $x>0$ but maybe that's not what you are talking about. 
