It seems reasonable to write $x^2=x+x+...+x$ ($x$ times) but we run into a problem with derivatives if we do this.

The derivative of $x^2$ is $2x$ but the derivative of the sum on the right hand side turns out to be $x$, which can't be possible..

My question is where do we commit a mistake here? Is it while writing $x^2$ as the sum or while differentiating that sum?