[guided]Assume that $X$ and $Y$ are independent. The goal is to prove equality of two functions, but densities are best compared through the measures they define. Let $A,B\in\mathcal B(\mathbb R)$. The set $A\times B$ is a Borel subset of $\mathbb R^2$, and the event $\{(X,Y)\in A\times B\}$ is exactly the event $\{X\in A,\ Y\in B\}$. Therefore
\begin{align*}
\mu(A\times B)
=
\mathbb P((X,Y)\in A\times B)
=
\mathbb P(X\in A,\ Y\in B).
\end{align*}
By independence of the random variables,
\begin{align*}
\mathbb P(X\in A,\ Y\in B)
=
\mathbb P(X\in A)\mathbb P(Y\in B).
\end{align*}
Now use the fact that $f_X$ and $f_Y$ are the chosen marginal densities:
\begin{align*}
\mathbb P(X\in A)
=
\int_A f_X(x)\,d\mathcal L^1(x)
\end{align*}
and
\begin{align*}
\mathbb P(Y\in B)
=
\int_B f_Y(y)\,d\mathcal L^1(y).
\end{align*}
Multiplying these two identities gives
\begin{align*}
\mathbb P(X\in A)\mathbb P(Y\in B)
=
\left(\int_A f_X(x)\,d\mathcal L^1(x)\right)
\left(\int_B f_Y(y)\,d\mathcal L^1(y)\right).
\end{align*}
The product of the two one-dimensional integrals is exactly the integral of the product density over the rectangle. Indeed, the function
\begin{align*}
(x,y)\mapsto \mathbb 1_A(x)\mathbb 1_B(y)f_X(x)f_Y(y)
\end{align*}
is non-negative and Borel measurable on $\mathbb R^2$. Hence the Fubini-Tonelli theorem applies and yields
\begin{align*}
\int_{A\times B} g(x,y)\,d\mathcal L^2(x,y)
=
\left(\int_A f_X(x)\,d\mathcal L^1(x)\right)
\left(\int_B f_Y(y)\,d\mathcal L^1(y)\right).
\end{align*}
Combining the previous identities gives
\begin{align*}
\mu(A\times B)=\nu(A\times B)
\end{align*}
for every pair $A,B\in\mathcal B(\mathbb R)$.
Why is equality on rectangles enough? The measurable rectangles form a $\pi$-system, meaning that the intersection of two such rectangles is again such a rectangle. They generate the full Borel $\sigma$-algebra $\mathcal B(\mathbb R^2)$. The class
\begin{align*}
\mathcal D=\{E\in\mathcal B(\mathbb R^2):\mu(E)=\nu(E)\}
\end{align*}
is a Dynkin system because $\mu$ and $\nu$ are finite measures: it contains $\mathbb R^2$, is closed under complements inside $\mathbb R^2$, and is closed under countable disjoint unions by countable additivity. Since $\mathcal D$ contains the rectangle $\pi$-system, the $\pi$-$\lambda$ theorem implies that $\mathcal D=\mathcal B(\mathbb R^2)$. Thus $\mu=\nu$ on all Borel subsets of $\mathbb R^2$.
Finally, both measures are represented by densities with respect to $\mathcal L^2$:
\begin{align*}
\mu(E)=\int_E f_{X,Y}(x,y)\,d\mathcal L^2(x,y)
\end{align*}
and
\begin{align*}
\nu(E)=\int_E g(x,y)\,d\mathcal L^2(x,y)
\end{align*}
for every $E\in\mathcal B(\mathbb R^2)$. Since $\mu=\nu$, these integrals are equal for every Borel set $E$. The uniqueness of non-negative Lebesgue densities then gives
\begin{align*}
f_{X,Y}(x,y)=g(x,y)=f_X(x)f_Y(y)
\end{align*}
for $\mathcal L^2$-a.e. $(x,y)\in\mathbb R^2$.[/guided]