Let $g = p_1 f : U \to X$. I claim that $f = \Delta g$. Since both are morphisms to $X \times_Y X$, it suffices to check this after composing with the projections. But we have $p_1 f = g = p_1 \Delta g$ and $p_2 f = p_1 f = g = p_2 \Delta g$.
PS: This has nothing to do with schemes, it holds in any category with products (here we apply this to the category of $Y$-schemes). Basically we have seen that $\Delta : X \to X \times X$ is the equalizer of the two projections. More generally, in any category, every split monomorphism is regular.