Let $X'$, $X$, and $Y$ be $S$-schemes. Let $f:X'\to X$ be an $S$-morphism such that $f_{x'}^{\#}$ is an isomorphism for all $x'\in X'$. Denote $g:=f\times_S \text{id}_Y:X'\times_SY\to X\times_SY$. Then does the equality $$g(X'\times_SY)=p^{-1}(f(X'))$$ hold? ($p$ is the first projection of $X\times_SY$)
I tried to prove the equality set-theoretically but it failed, but how can I use the isomorphism condition?
I forgot to say $f$ is a homeomorphism to its image.
This is true for any morphism $f$.
First, we have a commutative diagram $$\begin{matrix} X'\times_S Y & \stackrel{g}{\longrightarrow} & X\times_S Y\\ \downarrow p' &&\downarrow p\\ X'&\stackrel{f}{\longrightarrow}& X \end{matrix} $$ where $p'$ is the first projection. So $p\circ g=f\circ p'$, which implies that $$ g(X'\times_S Y)\subseteq p^{-1}(f(p'(X'\times_S Y)))\subseteq p^{-1}(f(X')).$$
Now let us prove the converse. Let $x=f(x')\in f(X')$. Then $p^{-1}(\{x\})$ can be identified with $\mathrm{Spec}\, k(x)\times_S Y$. As $g$ induces a morphism $$g_x: \mathrm{Spec}\, k(x')\times_S Y\to \mathrm{Spec}\, k(x)\times_S Y,$$ it is enough to show that $g_x$ is surjective. Let $Z=\mathrm{Spec}\, k(x)\times_S Y$. This is a scheme over $k:=k(x)$. Let $k'=k(x')$. This is a field extension of $k$, and we want to show $$q: Z_{k'}\to Z$$ is surjective. Let $z\in Z$. Then $q^{-1}(z)$ can be identified with the spectrum of $k(z)\otimes_k k'$. So $q^{-1}(z)\ne\emptyset$ is equivalent to $k(z)\otimes_k k'\ne 0$. But $k(z)\otimes_k k'$ contains $k(z)$ so is obviously non-zero.