If $E[Y \mid X]=X$ and $E[Y^2 \mid X]=X^2$. Then $Y=X$ a.s
My attempt:
Using the definition of conditional expectation we have that for all $A \in \sigma(X)$ $E[Y^2-X^2 1_A]=0$ so in particular $E[Y^2-X^2 1_{\{X=x\}}]=0$. Since we know that for $X\ge 0$ a.s $E[X]=0$ implies $X=0$ a.s., it is sufficient to show that $(Y^2-X^2)1_{\{X=x\}} \ge 0$ a.s.
$\textbf{Is this($(Y^2-X^2)1_{\{X=x\}} \ge 0$ a.s.) even true ?}$ How can I show this? I tried to reason using $E[Y \mid X]=X$ but I cant come up with anything which works. I am not looking for a solution but just a nudge in the right direction. I spent quite some time on this problem. If I could choose an $A\in \sigma(X,Y)$ , then the solution becomes clear.
Just check that the conditional variance is $$ {\rm Var}(Y|X)=\mathbb{E}[(Y-\mathbb{E}[Y|X])^2|X]=\mathbb{E}[Y^2|X]-(\mathbb{E}[Y|X])^2\geq 0. $$ In your problem, you deduce that this is exactly $0$, hence, $\mathbb{E}[(Y-\mathbb{E}[Y|X])^2 |X]=0$, thus, $Y=\mathbb{E}[Y|X]=X$. The end.