I suppose Fubini's Theorem is being used in $$\int_{- \infty}^{x} \int_y ^xg'(z)e^{-y^2/2}dzdy-\int _x ^{\infty}\int_x ^yg'(z)e^{-y^2/2}dzdy \\ =\int_{-\infty}^x g'(z) \int_{-\infty}^ze^{-y^2/2}dydz - \int_x ^\infty g'(z) \int_z ^\infty e^{-y^2/2}dyz$$
since the order of $dy, dz$ are swapped, but why don't the integrals (the elongated S's) change order and why do the limits of integration change?
I also tried evaluating the RHS but I get $\int_{-\infty}^x g'(z)(erf(\frac{z}{\sqrt 2}+1)dz-\int_x ^\infty g'(z) (1-erf(\frac{z}{\sqrt 2})dz= \int_{-\infty }^\infty g'(z) e^{-y^2/2}dz+ \int_{-\infty}^x g'(z)dz - \int _x ^\infty g'(z)dz$, whereas the left hand side of the original is $\int_{-\infty}^\infty e^{-y^2/2}(g(x)-g(y))dy$.
Consider a function $f(y,z)$ on two variables $z$ and $y$. Then $$\int_{-\infty}^x\left(\int_y^xf(y,z)dz\right)dy=\int_{-\infty}^x\left(\int_{-\infty}^x[z\geq y]f(y,z)dz\right)dy$$ where $[z\geq y]=1$ if $z\geq y$ and $0$ otherwise (i.e., $[z\geq y]$ is the Boolean value of the assertion "$z\geq y$". Anyway, it is simply another function on variables $z,y$).
Now we have an integral on two intervals $(-\infty,x]$ and $(-\infty,x]$. By Fubini, $$\int_{-\infty}^x\int_y^xf(z,y)dzdy=\int_{-\infty}^x\left(\int_{-\infty}^x[z\geq y]f(y,z)dy\right)dz=\int_{-\infty}^x\left(\int_{-\infty}^zf(y,z)dy\right)dz$$ Use this with $f(y,z)=g'(z)e^{-y^2/2}$ for the first integral. The second integral is similar.