Consider,
$$I = \int_{-\infty}^{\infty} e^{-x^2} dx$$
The trick is to multiply by $I$ again to get $I^2$ But they often write:
$$I^2 = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} e^{-x^2 - y^2} dy\space dx$$
The issue is orientation.
$I$ is an integral, which is orientated in the $xy$ plane, and $x$ is the independent variable, y is the dependent variable.
When you consider the other one with $e^{-y^2}$, then $y$ is the independent variable and $x$ is the dependent variable.
How does this work?
You want to think of $x$ and $y$ as two independent variables, and something else, say $z$, would be the dependent variable.
In the first integral, if you're thinking of $y$ as the dependent variable, rename it as $z$, and then add $y$ as a second independent variable.
Does that help?