Proving $\operatorname{Var}(X) = E[X^2] - (E[X])^2$

$\newcommand{\E}{\operatorname{E}}$It should not have been written as $$ \E[X\E[X]] = \E[\E[X]\E[X]]. $$ Instead, it should have said $$ \E[X\E[X]] = \E[X] \E[X]. $$ The justification is this: $$ \E[X\cdot5] = 5\E[X], $$ and similarly for any other constant besides $5$. And in this context, "constant" means "not random". So just treat $\E[X]$ the same way you treat $5$, because it's a constant.