So it is very well known that the conditional expectation minimizes the mean squared error. That is, given a probability space $(\Omega, \mathcal{A}, \mathbb{P})$ and random variables $X:(\Omega, \mathcal{A})\rightarrow (\mathcal{X}, \mathcal{F})$ and $Y:(\Omega, \mathcal{A})\rightarrow (\mathcal{Y}, \mathcal{G})$. Let $f:(\mathcal{X}, \mathcal{F}) \rightarrow (\mathcal{Y}, \mathcal{G})$ be measurable. The statement is then: $$\mathbb{E}[Y|X]\in \arg \min_{f}\mathbb{E}[(Y-f(X))^2] $$ The following statement is also true: $$ \mathbb{E}[Y|\mathcal{H}]\in \arg \min_{\{Z:(\Omega, \mathcal{H})\rightarrow (\mathcal{Y}, \mathcal{G})\}}\mathbb{E}[(Y-Z)^2],$$ for a sub-sigma algebra $\mathcal{H}\subseteq\mathcal{A}$.
I cannot bring these two statements into accordance. So my confusion comes from the fact that $\mathbb{E}[Y|X]:= \mathbb{E}[Y|\sigma(X)]$, where $\sigma(X)$ is the sigma-algebra generated by $X$ with $\sigma(X)\subseteq\mathcal{A}$. Hence, I would somehow assume that $f\circ X $ must be a mapping $(\Omega, \sigma(X)) \rightarrow (\mathcal{Y}, \mathcal{G})$. But this is not the case since $X:(\Omega, \mathcal{A})\rightarrow (\mathcal{X}, \mathcal{F})$. Can someone help?
EDIT: Thanks to the hint by Pantelis Tassopoulos I realized that I need the factorization lemma here: https://en.wikipedia.org/wiki/Doob%E2%80%93Dynkin_lemma
This lemma says for $(\mathcal{X}, \mathcal{F})\subseteq(\bar{\mathbb{R}}, \mathcal{B}(\bar{\mathbb{R}}))$ and $(\mathcal{Y}, \mathcal{G})\subseteq(\bar{\mathbb{R}}, \mathcal{B}(\bar{\mathbb{R}}))$ that $Z=f(X)$ is $\sigma(X)-\mathcal{G}$ measurable if and only if there exists a $\mathcal{F}-\mathcal{G}$-measurable function f such that $Z=f(X)$. Now, of course, $X$ is always $\sigma(X)-\mathcal{F}$-measurable. But since here we have even assumed that $X$ is $\mathcal{A}-\mathcal{F}$ measurable (which is not required for the lemma) we also know that $\sigma(X)\subseteq \mathcal{A}$. Hence due to the lemma we know that $Z=f(X)$ is $\sigma(X)-\mathcal{G}$ measureable. In fact we wouldnt even need the factorization lemma but only the fact that the composition of measureable maps is again measurable, in this case, that $Z=f(X)$ is $\sigma(X)-\mathcal{G}$ measureable.
BUT: $Z=f(X)$ is also $\mathcal{A}-\mathcal{G}$ measurable. In that case we would get as the argmin $\mathbb{E}[Y|\mathcal{A}] = \mathbb{E}[Y]$ (Is this equality actually true?). How do I now know that I should be using $f(X)$ as a $\sigma(X)-\mathcal{G}$ measurable function insted of a $\mathcal{A}-\mathcal{G}$ measurable here? I.e., if I just look at the problem $$\arg \min_{f}\mathbb{E}[(Y-f(X))^2] =?$$ I would right away treat $f(X)$ as a $\mathcal{A}-\mathcal{G}$ measurable function and hence I would get the wrong result.