Take two discrete random variables $X$ and $Y$. $X$ is an indicator random variable with $\mathbb{E}(X \mid Y) = 1/Y$. I want to compute
$$ \mathbb{E}((1 + 3X)Y^2). $$
The random variables are not independent.
The method I have seen does the following. First fix $Y$ and compute
$$\mathbb{E}((1 + 3X)Y^2) = Y^2 + 3Y.$$
Then compute
$$ \mathbb{E}((1 + 3X)Y^2) = \mathbb{E}(Y^2) + 3\mathbb{E}(Y). $$
How can this method be justified?