I read that if we're conditioning on a random variable ($X$ in our case), then to find $E[Y | X]$, we can simply first find $E[Y | X = x]$, then from this expression, we plug in $X$ everywhere we see $x$, and that gives us $E[Y | X]$. This seems very informal, so I'm hesitant to believe that this always works. Is this a sound approach to obtaining $E[Y | X]$?
Some examples include:
(1) $$ E[Y | X = x] = 5x^2 \implies E[Y | X] = 5X^3 $$
(2) $Y$ is the number of heads in 10 coin tosses. $X$ is the number of heads in 3 coin tosses.
$E[Y | X = x] = x + 7p \implies E[Y | X] = X + 7p$