$\newcommand{\vp}{\varphi}$ $\newcommand{\mc}{\mathcal}$ $\newcommand{\C}{\mathbb C}$
Let $(X, \mc X, \mu)$ be a probability space and $\mc F$ be subset of $L^2_\mu$. Let $\mc Y$ be the $\sigma$-algebra generated by $\mc F$. I want to show the following
Problem. Assuming $\mathcal F$ is an algebra*, I want to show that if $f\in L^2_\mu$ is $\mc Y$-measurable then $f$ can be approximated arbitrarily well in $L^2$ by linear combinations of products of functions in $\mc F$.
This was mentioned in here by @JohnGriesmer in this answer. Perhaps a better way to say the above is the following. Suppose $\mc A\subseteq L^2_\mu$ is an algebra, that is $\mc A$ is closed under products and linear combinations, and $\mc Y$ is the $\sigma$-algebra generated by $\mc A$. Then any $\mc Y$-measurable function in $L^2_\mu$ can be approximated arbitrarily well by members of $\mc A$.
Attempt.
I considered the problem in a simple case where I was able to show that the desired result indeed holds: Let $X$ be the unit interval $[0, 1]$ and $\mc X$ be the Borel $\sigma$-algebra on $X$. Let $\mu$ be the Lebesgue measure. Define $\mc F\subseteq L^2$ be the algbera generated by the singleton containing the function $\vp:=1_{[0, 1/2)} + 2\cdot 1_{[1/2, 1]}$, and $\mc Y$ be the $\sigma$-algebra generated by $\mc F$. For convenience write $A=[0, 1/2)$ and $B=[1/2, 1]$. Clearly, then $A$ is in $\mc Y$, and thus $f:=1_A$ is a $\mc Y$-measurable function. I want to show that $f$ can be approximated in $L^2$ by functions of the type $\sum_{k}c_k \vp^k$, where $c_k\in \C$. Note that $\vp^k = 1_A + 2^k\cdot 1_B$. Thus $\sum_k c_k\vp^k = (\sum_k c_k)1_A + (\sum_k 2^kc_k)1_B$. So if we can find $c_k$'s such that $\sum_k c_k$ is close to $1$ and $\sum_k 2^kc_k$ is close to $0$ then we can succeed with the approximation. And indeed such $c_k$ can be found.
But this toy case does not seems to lend to a generalization.
*: The assumption that $\mathcal F$ is an algebra was not present at first. @Rerain gave a counterexample and only then I have added this assumption. By an algbera we mean a linear subspace closed under products.
I think I've found a counterexample.
Let the probability space $(X,\mathcal{X},\mu)$ be given by$$X=[1,\infty),\quad \mathcal{X}=\mathcal{B}(X),\quad \mu([a,b])=\int_a^b 3x^{-4}\textrm{d}x$$and let $\mathcal{F} = \{g\}$ with $g:X\rightarrow\mathbb{R}, x \mapsto x$. Then$$\int_X |g^a|^2\textrm{d}\mu = \int_1^\infty 3x^{2a-4}\textrm{d}x \lt \infty \quad \iff \quad a\lt\frac{3}{2},$$so the only products of functions in $\mathcal{F}$ that are actually in $L_\mu^2$ are $g$ itself and $x \mapsto 1$ (the empty product).
On the other hand, $\mathcal{Y} = g^{-1}(\mathcal{B}(\mathbb{R})) = \mathcal{X}$, so $$f:X\rightarrow\mathbb{R}, x \mapsto \sqrt{x}$$ is $\mathcal{Y}$-measurable and in $L_\mu^2$. If we try to $L_\mu^2$-approximate $f$ with polynomials $p_n$, any greater-than-linear terms will blow up, so $p_n$ must be affine-linear. Let $q_{r,s}$ be the affine-linear function that is equal to $f$ at $r$ and $s$ (so $q_{r,r}$ is a tangent to $f$) and let $r_n$, $s_n$ be such that $1 \le r_n \le s_n$ and $p_n=q_{r,s}$ ($p_n$'s that aren't a tangent to or intersect twice with $f$ are worse approximations than those who are or do, so we can ignore them). Since $f$ is strictly convex, this implies:
If $1 \le r_n \le s_n \le 3$, then$$\int_X |p_n-f|^2\textrm{d}\mu \ge \int_3^\infty |p_n-f|^2\textrm{d}\mu \ge \int_3^\infty |q_{3,3}-f|^2\textrm{d}\mu \gt 0,$$
if $2 \le r_n \le s_n$, then$$\int_X |p_n-f|^2\textrm{d}\mu \ge \int_1^2 |p_n-f|^2\textrm{d}\mu \ge \int_1^2 |q_{2,2}-f|^2\textrm{d}\mu \gt 0,$$
and if $1 \le r_n \le 2$ and $3 \le s_n$, then$$\int_X |p_n-f|^2\textrm{d}\mu \ge \int_2^3 |p_n-f|^2\textrm{d}\mu \ge \int_2^3 |q_{2,3}-f|^2\textrm{d}\mu \gt 0.$$
Every $p_n$ falls under at least one of the three cases and the rightmost integrals are independent of $n$, so $p_n$ cannot $L_\mu^2$-converge against $f$.