It's a late answer, but it might be useful for anyone reading it.
For a random variable $X$, $E(X^{2})= [E(X)]^{2}$ iff the random variable $X$ is independent of itself. This follows from the property of the expectation value operator that $E(XY)= E(X)E(Y)$ iff $X$ and $Y$ are independent random variables. In the case of a single type of random variable $X$, this statement reduces down to the statement that the random variable is independent of itself.
Statement: Two random variables are independent iff:
$\mathrm{F}_{XY}(x,y)= \mathrm{F}_{x}(x)\mathrm{F}_{y}(y); $ for all $X= x$, $Y=y$
where $\mathrm{F}_{X}(x)$, $X= x$ denotes the cumulative distribution function of an arbitrary random variable $X$. Now as this answer also suggests, a random variable can be independent of itself iff it realizes a fixed (constant) value. This follows from:
$\mathrm{F}_{XX}(x,x)=\mathrm{F}_{X}(x)=\mathrm{F}_{X}(x)\mathrm{F}_{X}(x)$
and $\mathrm{F}_{X}(x)\in$ {$0,1$}, for any $X= x$. The only way for the cumulative distribution function to realize the value $1$ for any $X= x$ is for random variable $X$ to be a constant, i.e., $X= x_{0}$, where $x_{0}$ is the (only) element of the (possibly only) non-empty subset (i.e. a singleton) of the $\sigma$-algebra of the set $E$ (not the expectation value), which is the set of all of values that the random variable $X$ can realize (a more rigorous proof for this last step may require a measure-theoretic approach).
Notice that $E(X^{2})= [E(X)]^{2}$ also implies $E(X^{2})-[E(X)]^{2}=0 \Rightarrow Var(X)=0$, which is always satisfied for a constant random variable $X$. This can also give an intuition for the reasoning above.
Therefore, $E(X^{2})\neq [E(X)]^{2}$ in general.