The variable has to be on its own in the equation, otherwise you are integrating a variable ax with respect to dx and they are different.

You can do a change of variables, let y=ax

Then the integral

becomes

Presumably in the derivation of the solution to the integral, x^{2}is not multiplied by a constant and the proof cannot be done the same way when x^{2}is multiplied by a constant