Let $X,Y$ be random variables on $(\Omega, \mathcal{F}, P)$ and $\mathcal{G}\subseteq \mathcal{F}$ a $\sigma-$field
If $E[Y\vert \mathcal{G}]=X$ and $E[X^2]=E[Y^2]<\infty$ then show $X=Y$ a.s.
I don't know where to start so I guess I will define the event $A:=\{X\neq Y\}$ from $E[Y\vert \mathcal{G}]=X$, I know that for $B \in \mathcal{G}: \int_{B}YdP=\int_{B}XdP$
and then somehow I need to show that $\int_{B\cap A}YdP=\int_{B\cap A}XdP=0$
I do not know how $E[X^2]=E[Y^2]$ is supposed to help me
The idea of the proof is to show that $E(X-Y)^2=0$ from which it would follow that $X=Y$ a.s. (In general if $Z\geq 0$ w.p.1 and $EZ=0$, then $Z=0$ w.p.1)
To this end we will use the tower law and compute $$ \begin{align} E[(X-Y)^2\mid \mathcal{G}]&=E[X^2-2XY+Y^2\mid \mathcal{G}]\\ &=E(X^2\mid \mathcal{G})-2E(XY\mid \mathcal{G})+E(Y^2\mid \mathcal{G})\tag{0}\\ &=X^2-2XE(Y\mid \mathcal{G})+E(Y^2\mid \mathcal{G})\tag{1}\\ &=E(Y^2\mid \mathcal{G})-X^2 \end{align} $$ where in (0) we use linearity and in (1) we use the fact that $X=E(Y\mid \mathcal{G})$ whence $X\in \mathcal{G}$ and use the pullout property.
The tower law implies that $$ E(X-Y)^2=EY^2-EX^2=0 $$ as desired.