That is indeed quite a confusing way to put it. The idea is that for any $y \in Y$, you can find an $x$, written as $g(y) = x$, such that $f(x) = y$. Below I have written a few things out, also for injective maps (because the idea is similar) and I hope this makes it more clear.
Suppose $f : X \to Y$ is a function. Then
- $f$ is surjective iff for each $y \in Y$, there exists an $x \in X$ such that $f(x) = y$.
"$f$ is able to reach every point $y$ in the codomain $Y$"
- $f$ is injective iff for all $x_1, x_2 \in X$ we have $f(x_1) = f(x_2)$ implies that $x_1 = x_2$.
"$f$ maps distinct elements in the domain to distinct elements in the codomain"
Now suppose there exists $g : Y \to X$ such that $f(g(y)) = y$ for all $y \in Y$. This implies that $f$ is surjective. This easily follows from the definition. The reverse is also true (actually, only if you assume the axiom of choice, but if you have never heard of this, you should not mind it. see also: Why the fact that surjective map has an inverse at right is equivalent to axiom of choice?).
You want to define $g : Y \to X$ such that $f(g(y)) = y$ for each $y \in Y$, and you do this as follows: for any $y \in Y$, we know by surjectivity that there exists $x \in X$ such that $f(x) = y$, now use this $x$ to define $g(y) = x$. This defines the required map $g : Y \to X$.
For injective maps something similar works. Suppose there exists $g : Y \to X$ such that $g(f(x)) = x$ for all $x \in X$. In a similar way, this implies that $f$ is injective. (Why?) The reverse direction is also true: if $f$ is injective, you can show yourself that there exists $g : Y \to X$ such that $g(f(x)) = x$ for all $x \in X$.
Note: I'm using some informal terminology and methods.
– nickalh Mar 26 '24 at 10:36