There is a lemma in Stacks Project saying that points $z$ of $X \times_S Y$ are in bijective correspondence to quadruples $$ (x, y, s, \mathfrak p) $$ where $x \in X$, $y \in Y$, $s \in S$ are points with $f(x) = s$, $g(y) = s$ and $\mathfrak p$ is a prime ideal of the ring $\kappa(x) \otimes_{\kappa(s)} \kappa(y)$.
I met a problem when checking the two constructions are inverse to each other. When given some quadruples $ (x, y, s, \mathfrak p) $, we get a $z$ in the lemma, and then we have another quadruple $ (x, y, s, \mathfrak q) $ corresponding to $z$. But why $\mathfrak p =\mathfrak q$ ? In other words, why the $\mathfrak p$ in the second paragraph of the proof is also the kernel of $\kappa(x) \otimes_{\kappa(s)} \kappa(y) \to \kappa(z)$. I only know $\mathfrak p \subset\mathfrak q$.
Here is an alternative proof.
Recall the notion of a fiber of a morphism of schemes and that its underlying set is really the fiber of the underlying maps. Hence, if $x \in |X|$ is a point, the fiber of $X \times_S Y \to X$ at $x$ is $\mathrm{Spec}(\kappa(x)) \times_X (X \times_S Y) = \mathrm{Spec}(\kappa(x)) \times_S Y$. The fiber of $\mathrm{Spec}(\kappa(x)) \times_S Y \to Y$ at $y \in |Y|$ is $\mathrm{Spec}(\kappa(x)) \times_S \mathrm{Spec}(\kappa(y))$, and the fiber of $ \mathrm{Spec}(\kappa(x)) \times_S \mathrm{Spec}(\kappa(y)) \to S$ at $s \in |S|$ is $\mathrm{Spec}(\kappa(x)) \times_{\mathrm{Spec}(\kappa(s))} \mathrm{Spec}(\kappa(y))$. It follows that the fiber of $|X \times_S Y|\to |X| \times_{|S|} |Y|$ at $(x,y,s)$ is $|\mathrm{Spec}(\kappa(x) \otimes_{\kappa(s)} \kappa(y))|$.