Suppose that $\mathcal{G}$ is a sub-$\sigma$-algebra of $\mathcal{F}$, and that $X$ and $Y$ are random variables with the property that $$ \mathbb{E}[X | \mathcal{G}] = Y \quad \text{and} \quad \mathbb{E}[X^2 | \mathcal{G}] = Y^2.$$ Show that $X = Y$ almost surely.
This is a problem in Allan Gut's book. I don't want hints for a solution (as of now). I only need you to find the mistake I'm doing.
"Counterexample": If $\mathcal{G} = \{\emptyset, \Omega \}$ where $\Omega$ is the whole space, then we only get the information $\mathbb{E}[X] = \mathbb{E}[Y]$ and $\mathbb{E}[X^2] = \mathbb{E}[Y^2]$ which is clearly not enough to deduce $X = Y$ almost surely.
Observe that $Y$ and $Y^2$ are measurable wrt $\mathcal G=\{\varnothing,\Omega\}$ which means that they are constant, hence equal to their expectations.
The information that you gain is $Y=\mathbb EX$ and $Y^2=\mathbb EX^2$.
This implies that $\mathsf{Var}(X)=\mathbb EX^2-(\mathbb EX)^2=Y^2-Y^2=0$.
So $X$ must be degenerated, i.e. constant almost surely.
Then $X=\mathbb EX=Y$ almost surely.