Is differentiating on both sides of an equation allowed? Let's say we have $x^2=25$
So we have two real roots ie $+5$ and $-5$.
But if we were to differentiate on both sides with respect to $x$ we'll have the equation $2x=0$ which gives us the only root as $x=0$.
So does differentiating on both sides of an equation alter it? If it does, then how do we conveniently do it in Integration by substitutions?
If not then what exactly is going on here ?

mcb's answer suggests that the equal sign doesn't always have the same meaning. I disagree, the difference is in the role of $x$. When we write $(x-1)(x+1)=x^2-1$, we mean that for all $x$, $(x-1)(x+1)=x^2-1$. When we write $x^2=25$, it means for which $x$ is $x^2=25$ ? (Answer: $x=-5$ and $x=+5$). 
In the first case, $x$ is used to denote any value from the function domain, whereas in the second example $x$ denotes a specific value from the function domain which corresponds to a given value in the codomain.
How does this apply to the question? Differentiating means calculating (f(x+dx)-f(x))/dx as dx goes to zero. This means evaluating f(x) at and around x. Now if f(x) and g(x) are only equal at a specific point x, then they're not equal at x+dx. That means f'(x) ≠ g'(x).
