I've thought that since
$$ f(x) = |x|^2 = \begin{cases} (-x)^2, & \mbox{if } x \leq 0 \\ x^2, & \mbox{if } x > 0 \end{cases} = \begin{cases} x^2, & \mbox{if } x \leq 0 \\ x^2, & \mbox{if } x > 0 \end{cases},$$
the derivative of $f(x)$ would be $2x$. However, it seems that it is, actually, only differentiable at $x = 0$. But why?
Sorry, folks. I was talking about $x$ as a complex variable. So, if $x = a + i\ b$ and $f(x) = u(a,b) + i\ v(a,b) =|x|^2 = a^2 + b^2 $, then $\frac{\partial u}{\partial a} = 2a$, $\frac{\partial v}{\partial b} = 0$, $\frac{\partial u}{\partial b} = 2b$ and $\frac{\partial v}{\partial a} = 0$. Therefore, the Cauchy-Riemann condition is only satisfied when $a = b = 0$, so the function is only analytic at $z=0$.
P.S.: I've made this confusion because I had calculated the derivative of |x|^2 using Mathematica (without saying if it was either real or complex) and the answer was not defined for $x\ne 0$. So, I've thought that this was also the answer for real variables too.