I cannot really understand how we did simplification for our variance. Like how we got E[X^2] on the second line. Probably some algebra gaps.. but I cannot really make sense of it. Need help! Thank you.

$$\begin{align}
& = \sum\_xx^2p(x) - 2\mu\sum\_xxp(x)+\mu^2\sum\_xp(x) \\
& = E[X^2] - 2\mu^2+\mu \\
&= E[X^2] - \mu^2
\end{align}$$

... how then from this we got 

$$Var(X) = E[X^2] - E([X])^2$$