Let $f: X \to Y$ a morphism between $S$-schemes where $Y$ is a separated $S$-scheme. Therefore the diagonal morphism $Y \to Y \times_S Y$ is a closed immersion.
Let $\Gamma_f = (id,f): X \to X \times_S Y$ the graph morphism.
Why and how to see that $\Gamma_f $ is a closed immersion.
Let the structure maps of $X$ and $Y$ as $S$-schemes be $u$ and $v$, respectively, so that $u=v\circ f$.
As mentioned in the comments, we want to check $$\require{AMScd} \begin{CD} X @>{\Gamma_f}>> X\times_SY\\ @V{f}VV @V{f\times Y}VV \\ Y @>{\Delta_Y}>> Y\times_SY \end{CD}$$ is a fibered product. We may check this locally [the commuting diagram produces a morphism of schemes $X\to Y\times_{Y\times_SY}(X\times_SY)$, and we may check this is an isomorphism locally], so let $U=\mathrm{Spec} R\subset S$ be an affine open set, $W=\mathrm{Spec} B\subset v^{-1}(U)\subset Y$, and $V=\mathrm{Spec} A\subset f^{-1}(W)\subset X$. Now the diagram solely consists of affine schemes: $$\require{AMScd} \begin{CD} V @>{\Gamma_{f|_V}}>> V\times_UW\\ @V{f|_V}VV @V{f|_V\times W}VV \\ W @>{\Delta_Y}>> W\times_UW \end{CD}$$
Suppose $f\colon V\to W$ is given by $\varphi\colon B\to A$. Then in the category of commutative rings the diagram becomes:
$$\require{AMScd} \begin{CD} A @<{\gamma}<< A\otimes_RB\\ @A{\varphi}AA @A{\varphi\otimes B}AA \\ B @<{\delta}<< B\otimes_RB \end{CD}$$ where $\gamma(a\otimes b):=a\varphi(b)$ and $\delta(b_1\otimes b_2)=b_1b_2$. Now following the diagram gives $$\varphi\circ\delta(b_1\otimes b_2)=\varphi(b_1b_2)=\varphi(b_1)\cdot\varphi(b_2)=\gamma(\varphi(b_1)\otimes b_2)=\gamma\circ(\varphi\otimes B)(b_1\otimes b_2),$$ so it indeed commutes.
To show this is a pullback diagram: We want to show $A\cong B\otimes_{B\otimes_RB}(A\otimes_RB)$. We have maps:
$$A\to B\otimes_{B\otimes_RB}(A\otimes_RB):a\mapsto1\otimes(a\otimes1)$$ and $$B\otimes_{B\otimes_RB}(A\otimes_RB)\to A:b_1\otimes(a\otimes b_2)\mapsto \varphi(b_1b_2)a.$$ There are a couple of things to check here: