Why is the mean value E[X(t) cos(2πft)]=cos(2πft) E[X(t)] ? X(t) We can take f as a constant , but can this equality be applied every time we have a cos in the mean value?
This a part of an exercise where in the given solution this is applied
Where the probability of f=fc is 9/10 and f=fc+ε is 1/10

In your image, the expectation is being taken not with respect to $t$ (or $\tau$), but with respect to a random event on which the value of $f$ depends. With probability $\frac9{10}$, $f$ takes the value $f_c$, and with probability $\frac1{10}$ it takes the value $f_c+\epsilon$. Then by the definition of the expectation, we have
\begin{eqnarray*} \mathbb E\left[\frac{A^2}2\cos(2\pi ft)\right] &=& \mathbb P(f=f_c)\frac{A^2}2\cos(2\pi f_ct)+\mathbb P(f=f_c+\epsilon)\frac{A^2}2\cos(2\pi (f_c+\epsilon)t) \\ &=& \frac9{10}\cdot\frac{A^2}2\cos(2\pi f_ct)+\frac1{10}\cdot\frac{A^2}2\cos(2\pi (f_c+\epsilon)t)\;. \end{eqnarray*}
This is a thoroughly unmysterious application of the expectation operator and has nothing to do with the equation that you surmised from it. The only thing that we can take outside the expectation operator here is $\frac{A^2}2$, which doesn't depend on $f$.