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 ?

If we take $x^2 = 25$ as given, then it is indeed true that
$$ 2x \, \mathrm{d}x = 0 $$
your mistake is the supposition that this implies $2x = 0$; among the alternatives is that it is $\mathrm{d}x$ that vanishes, and consequently it does not make sense to take the "derivative with respect to $x$", for similar reasons that it doesn't make sense to divide by zero.
You're used to doing calculus in settings where the variables actually have room to vary, but that is not the case here: the entire domain over which $x$ is allowed to vary is the zero-dimensional set consisting of the two points $\pm 5$.
Zero dimensional calculus is degenerate and rather boring; variables don't have any room to vary continuously, and thus everything is (locally) constant and $\mathrm{d}u = 0$ no matter what $u$ is.

This kind of reasoning is more useful in higher dimension; e.g. two variables related by one equation (as you have when doing an integral substitution) is nondegenerate; in fact, it fits nicely into the single-variable calculus framework.
You can do more than $u$ substitutions too; there are other sorts of algebraic and geometric things you can do. e.g. to work in the unit circle, we can take as a given that the two dependent variables $x$ and $y$ satisfy
$$ x^2 + y^2 = 1 $$
from which we infer that
$$ 2x \, \mathrm{d}x + 2y \, \mathrm{d}y = 0 $$
which has various algebraic and geometric content. e.g. we can solve for
$$ \frac{\mathrm{d}y}{\mathrm{d}x} = -\frac{x}{y} $$
or we can quickly determine the tangent line at a point; e.g. the tangent line to $(0.6, 0.8)$ satisfies $1.2 \mathrm{d}x + 1.6 \mathrm{d}y = 0$. Since the tangent line varies in the same way the circle does at a point, the tangent line must have the form $1.2 x + 1.6 y = c$ for some constant $c$. Plugging in the given point gives $1.2 x + 1.6 y = 2$. 

(plot generated by this wolfram alpha command)
