I saw this proof in MIT Probability Courseware :
I understand the linearity of expectation and went through the proof of it as well. But how is the Expectation distributed over a quadratic function here in the second step of the proof ?
To clarify, I want to understand what allows us to distribute
\begin{align}E(X^2 + a)&=E(X^2) + E(a)\end{align}
This is not linear in X, so linearity of expectation shouldn't hold ?!
Further clarification :
I am also told in the course (Slide 2), to not assume :
E[g(X)] = g(E[X]) to be true in general.
If I could do change of variables like suggested by some answers, the above can always be made to be true ?

Remember for a constant, $E(kX)=kE(X)$, $-2\mu$ and $\mu^2$ ara constants.
\begin{align}E(X^2-2\mu X+\mu^2)&=E(X^2)-E(2\mu X)+E(\mu^2)\\&=E(X^2)-2\mu E( X)+\mu^2 E(1)\\&=E(X^2)-2\mu E( X)+\mu^2 \end{align}
Edit:
Let $Y=X^2$, then $Y$ is a random variable. hence the problem becomes $E(Y-2\mu X+\mu^2)$.
Edit $2$:
If you let $Y=g(X)$, $E(g(X))=E(Y)$, the $g$ doesn't get out from the expectation in general, in the context of $g(X)=X^2$, note that the quadratic stays inside the expectation term. In general $E(X^2) \ne E(X)^2$.