Here’s how to prove that
$$E[(y-\mu)^{T}A(y-\mu)]=E(y^{T}Ay)-\mu^{T}A\mu,$$
when $A$
is a matrix and $y$
a random vector with mean vector $\mu$
.
$$\begin{eqnarray*} E[(y-\mu)^{T}A(y-\mu)] & = & E(y^{T}Ay-\mu^{T}Ay-y^{T}A\mu+\mu^{T}A\mu)\\ & = & E(y^{T}Ay)-E(\mu^{T}Ay)-E(y^{T}A\mu)+\mu^{T}A\mu \end{eqnarray*}$$
Here
$$E(\mu^{T}Ay)=\mu^{T}AE(y)=\mu^{T}A\mu,$$
by linearity of the expectation operator. Likewise,
$$E(y^{T}A\mu)=E(y)^{T}A\mu=\mu^{T}A\mu,$$
and
$$E(y^{T}Ay)-E(\mu^{T}Ay)-E(y^{T}A\mu)+\mu^{T}A\mu=E(y^{T}Ay)-\mu^{T}A\mu$$
as claimed.