- First, we prove that for all $f \in S(X\times Y)$ and $\varepsilon >0$. There is $f_\varepsilon \in S(X\times Y)$ such that $g$ satisfies $(*)$ and that $\lambda (A) \le \varepsilon$ where $A := \{f \neq f_\varepsilon \} \in \mathcal C$.
a. First, we consider the case $f = 1_C$ for some $C \in \mathcal C$ with $\lambda(C) < \infty$. Let
$$
\mathcal E := \bigg \{ \bigcup_{i \in I} A_i \times B_i : I \text{ finite}, A_i \in \mathcal A, B_i \in \mathcal B \bigg \}.
$$
Lemma 1 Let $\lambda$ be finite and $\mathcal D \subset \mathcal C$ an algebra generating $\cal C$. Then for each $C \in\cal C$ and $\varepsilon>0$, there is $D \in \cal D$ such that
$$
\mu(C\Delta D) := \mu(C\setminus D) + \mu(D \setminus C) < \varepsilon.
$$
Then $\cal E$ is an algebra generating $\cal C$. By above Lemma 1, there are $A_{k} \in \cal A$ and $B_{k} \in \cal B$ with finite measures such that
$$
\lambda \bigg ( C \Delta \bigg ( \bigcup_{k=1}^{{n}} A_{k} \times B_{k} \bigg) \bigg ) < \varepsilon
$$
Lemma 2 Let $(A_k \times B_k)_{k=1}^n$ where $A_k \in \mathcal A$ and $B \in \mathcal B$ with finite measures. Then there is a pairwise disjoint sequence $(A'_k \times B'_k)_{k=1}^{n'}$ such that
- $A'_k \in \mathcal A$ and $B'_k \in \mathcal B$ with finite measures,
- either $A'_{i} \cap A'_j = \emptyset$ or $A'_{i} = A'_j$,
- either $A'_{i} \cap A_j = \emptyset$ or $A'_{i} \subset A_j$,
- either $B'_{i} \cap B'_j = \emptyset$ or $B'_{i} = B'_j$,
- either $B'_{i} \cap B_j = \emptyset$ or $B'_{i} \subset B'_j$, and
$$
\bigcup_{k=1}^n A_k \times B_k = \bigcup_{k=1}^{n'} A'_k \times B'_k.
$$
WLOG, we assume $(A_{k} \times B_{k})$ satisfies the conclusion of Lemma 2. Then
$$
1_{\bigcup_{k=1}^{{n}} A_{k} \times B_{k}} = f_\varepsilon (x, y):= \sum_{k=1}^{{n}} 1_{A_{k}} (x) 1_{B_{k}} (y).
$$
Clearly, $f_\varepsilon \in S(X \times Y)$ has our desired form with
$$
A = C \Delta \bigg ( \bigcup_{k=1}^{{n}} A_{k} \times B_{k} \bigg).
$$
b. Next we consider the case $f \in S(X\times Y)$. We assume $f$ has a form $f = \sum_{n=1}^m e_n 1_{C_n}$. Let $f_{\varepsilon, n}$ be the approximating function for $1_{C_n}$ as in part (a) such that $\lambda(A_n) < \frac{\varepsilon}{n}$ where $A_n := \{f \neq f_\varepsilon \} \in \mathcal C$. Let
$$
f_{\varepsilon, n} (x, y) = \sum_{k=1}^{\varphi_{n}} 1_{A_{n, k}} (x) 1_{B_{n, k}} (y),
$$
and
$$
f_\varepsilon (x, y) := \sum_{n=1}^m e_n f_{\varepsilon, n} (x, y) = \sum_{n=1}^m \sum_{k=1}^{\varphi_{n}} e_n 1_{A_{n, k}} (x) 1_{B_{n, k}} (y).
$$
Clearly, $(A_{n, k} \times B_{n, k})_k$ does not necessarily satisfy our requirement, i.e., it's possible that
$$
\emptyset \neq A_{n', k'} \cap A_{n, k} \neq A_{n, k}.
$$
However, we can apply Lemma 2 to decompose them into our desired form. Clearly, $f_\varepsilon \in S(X \times Y)$ and $\lambda(A) \le \sum_{n=1}^m \lambda (A_n) \le \varepsilon$.
- Finally, we come back to our original problem. Let $f \in L^0(X \times Y)$. There is a sequence $(f_n) \subset S(X \times Y)$ such that $f_n \to f$ $\lambda$-a.e. Let $g_n$ be the approximating function of $f_n$ as in part (1) such that $\lambda (A_n) \le 2^{-n}$ where $A_n := \{f_n \neq g_n\}$.
Let $B_n := \bigcup_{k=1}^\infty A_{n+k} \in \mathcal C$. Then $\lambda(B_n) \le 2^{-n+1}$. Let $B := \bigcap_n B_n$. Then $B$ is a $\lambda$-null set. Let $N$ be a $\lambda$-null set such that $f_n \to f$ on $N^c$. We will prove that $g_n \to f$ on $(B \cup N)^c = B^c \cap N^c$. Let $(x, y) \in B^c \cap N^c$. There is $m \in \mathbb N$ such that $(x, y) \in B_m^c = \bigcap_{k=1}^\infty A_{m+k}^c$. Then $(x, y) \in A_{n}^c$ and thus $f_n (x, y) = g_n (x, y)$ for all $n>m$. On the other hand, $(x, y) \in N^c$ and thus $f_n (x, y) \to f(x, y)$. It follows that $g_n (x, y) \to f(x, y)$. This completes the proof.
Update In part (1), it's obvious that given $p \in [1, \infty)$ we can pick $f_\varepsilon$ that in addition satisfies $\|f -f_\varepsilon\|_{L^p} \le \varepsilon$.