$Y$ is supposed to be in $L^2(\Omega,\mathcal{A},P)$. From the definition of conditional expectation, I have derived that $E\{X^2 Z\}=E\{Y^2 Z\}, E\{XZ\}=E\{YZ\}$ for all $Z\in L^2(\Omega,\sigma(X),P)$ where $\sigma(X)$ is the $\sigma$-algebra generated by random variable $X$.
I tried to deduce as follows: $E\{XZ\}=E\{YZ\}\Longrightarrow E\{(X-Y)Z\}=0$. Since this is true for all $Z\in L^2(\Omega,\sigma(X),P)$, there should be $X-Y=0$. Similarly, $X^2-Y^2=0$. But this seems incorrect.
Please help me. Thanks in advance for any help.
Hint
There's a simpler way of obtaining the result than the way you're proposing to do it. What is $$ E\big((Y-X)^2\big|X\big)\ ? $$