Firstly we know that function $y=x^2$ is continuous and differentiable in R. If it is differentiable we can calculate a derivative $y'=2x$. We also know that if a point 'z' is the local min/max, then $f'(z)= 0$. That is why we may check how our derivative is behaving for different x. In this case:
- for every $x > 0$ our $f'(x) > 0$
- for every $x < 0$ our $f'(x) < 0$
- if $x = 0$ our $f'(x) = 0$
So by the rule I wrote above the only point where we should look for a local min/max is $x=0$, although it is not sufficient yet to tell that it is for sure a local min/max.
The sufficient condition for that is that in point 'z' the derivative must change its sign.
Let's assume we have a very small $r>0$ and we try to assess whether point 'z' is a local minimum. Then in interval (r, z] $f'(x) < 0$ (that means the function in this interval is decreasing) and in [z, r) $f'(x) > 0$ (that means the function in this interval is increasing). If such happens we can say that 'z' is local minimum.
That is why we can't say that for $y=x^2$ defined on interval [1,2] x=1 is local minimum. Because we know that on some interval [1, r) function is increasing, but we don't know what happens in (r, 1]. In other words we can't evaluate local min/max when there is only one-sided derivative in a point.