It seems to me that in the global case the answer should be $no$ because of the following argument. Set $S:=Spec$ $k[x,y,z]/(z^2-xy)$. Then $S$ is isomorphic to a quadric cone in $\mathbb{A}^3$ and the morphism $f \colon \mathbb{A}^2 \to S$ corresponds to a double cover branched on the vertex of the cone and on a smooth conic. Now you can repeat the same construction by taking a double cover $f_k \colon Y_k \to S$ branched on the vertex of the cone and on a smooth curve of $even$ degree $2k$ not passing through the vertex. The fact that $f_k$ is branched at the vertex ensures that $Y_k$ is smooth. When $k=1$ we have $Y_1=\mathbb{A}^2$, $f_1=f$. When $k=2$, $Y_2$ is an affine subset of a smooth surface of general type with $p_g=4, q=0, K^2=5$. These surfaces were studied by Horikawa in his famous paper "On deformations of quintic surfaces"; it turns out that the double cover is actually the canonical map. Of course $f_2$ does not factor through $f$, since they are covering of the same degree but $Y_2$, being of general type, is not isomorphic to $\mathbb{A}^2$.