More generally, it suffices to demand one of the maps to be an immersion:
If $f: X \to Y$ is an immersion, and $g: X \to Z$ is any morphism (all over $S$), then $X \to Y \times_S Z$ is an immersion.
Proof: $X \to Y \times_S Z$ is the composition of the graph-morphism $\Gamma_g = (\text{id}_X, g): X \to X \times_S Z$ with the product morphism $f \times \text{id}_Z: X \times_S Z \to Y \times_S Z$. We will show that both $\Gamma_g$ and $f \times \text{id}_Z$ are immersions.
For $f \times \text{id}_Z$ this is true, because a product of two immersions is an immersion.
The morphism $\Gamma_g$ can be obtained by base extension of the diagonal map $\Delta: Z \to Z \times_S Z$ along $X \times_S Z \xrightarrow{g \times \text{id}_Z} Z \times_S Z$, i.e. the following commutative diagram is cartesian:
$$
\begin{matrix}
X & \longrightarrow & Z \\
\Gamma_g \downarrow &&\downarrow \Delta \\
X \times Z & \longrightarrow &Z \times Z
\end{matrix}
$$
To conclude, $X \to Y \times_S Z$ is the composition of two immersions, so an immersion as well.
Note: The following is not true: if $f: X \to Y$ is a closed immersion, then $(f,g):X \to Y \times_S Z$ is a closed immersion. For this we would need that $Z$ is separated over $S$, so $\Delta: Z \to Z \times_S Z$ is a closed immersion.