[proofplan]
We form, for each point $y \in Y$, the fibre of $p$ over $y$. Surjectivity says exactly that each such fibre is nonempty. The [Axiom of Choice](/page/Axiom%20of%20Choice) then selects one element from each fibre, and the resulting selection function is a right inverse because its value over $y$ lies in the fibre over $y$.
[/proofplan]
[step:Build the nonempty fibres indexed by $Y$]
For each $y \in Y$, define the fibre set
\begin{align*}
A_y := p^{-1}(\{y\}) = \{x \in X : p(x) = y\}.
\end{align*}
This defines an indexed family $(A_y)_{y \in Y}$ of subsets of $X$. Since $p: X \to Y$ is surjective, for every $y \in Y$ there exists $x \in X$ such that $p(x) = y$. Hence $x \in A_y$, so $A_y \neq \varnothing$ for every $y \in Y$.
[/step]
[step:Choose one element from each fibre]
By the Axiom of Choice applied to the indexed family $(A_y)_{y \in Y}$ of nonempty sets, there exists a function $s: Y \to X$ such that
\begin{align*}
s(y) \in A_y
\end{align*}
for every $y \in Y$.
[/step]
[step:Verify that the chosen section is a right inverse]
Let $y \in Y$. Since $s(y) \in A_y$ and $A_y = \{x \in X : p(x) = y\}$, we have
\begin{align*}
p(s(y)) = y.
\end{align*}
Therefore, for every $y \in Y$,
\begin{align*}
(p \circ s)(y) = p(s(y)) = y = \operatorname{id}_Y(y).
\end{align*}
Thus $p \circ s = \operatorname{id}_Y$, so $s$ is a right inverse of $p$.
[/step]