I am puzzled by the question of how to define surjectivity in the light of the set-theoretical definition of functions.
A function $f : A \rightarrow B$ from a set $A$ to a set $B$ is a subset $f \subseteq A \times B$ of the Cartesian product $A \times B$ such that the following conditions hold:
- $\forall a \in A : \exists b \in B : (a,b) \in f$
- $\forall a \in A : \forall b, b' \in B : (a,b), (a,b') \in f \rightarrow b=b'$
Both conditions encode the idea that for every value $a \in A$ there exists a unique output value $b \in B$.
A function $f : A \rightarrow B$ is surjective if
- $ \forall b \in B : \exists a \in A : f(a) = b$.
We note that the notion of a function being surjective depends on the codomain of the function; by enlarging the codomain the function loses any surjectivity and by shrinking the codomain a function may eventually become surjective.
However, in the set-theoretical definition of functions we identify functions by their graph, which is enough to recover the domain $A$ and the image $f(A)$, but not enough to recover the codomain $B$.
For example, the identity function $f : \{0\} \rightarrow \{0\}$ is surjective and can be identified with its graph: $f = \{ (0,0) \} \in \{0\} \times \{0\}$. However, this is also the graph of the non-surjective function $f : \{0\} \rightarrow \mathbb R$.
It seems intuitive to me the "same" function with different codomains is actually different functions. Consequently, the codomain should be included as information when we define a "function object" in mathematics.
There are two incompatible, but closely related, definitions of what a function is. The category-theoretic definition has an associated set-theoretic definition, and this is that a function $f$ is a triple $(X, Y, G)$, where $X$ and $Y$ are sets, and $G\subseteq{X\times{Y}}$, such that $G$ satisfies the two axioms you listed. In this context, $X$ is the domain, and $Y$ is the codomain, and so, the definition of surjectivity as stated in the book is actually meaningful, since changing the codomain changes what the function itself is.
Now, notice that if I replace $Y$ with a superset of $Y$, I still have a function, although it is a different function than the one I started with. If I replace $Y$ with $f[X]$, then I get a third function, and this one is actually surjective. However, if I change $Y$ to a proper subset of $f[X]$, the resulting relation ceases to be a function, unless you want to consider it as a partial function, which is typically not preferred in mathematics outside some very limited contexts.
This brings us to the other definition of a function. Rather than defining a function $f$ as a triple $(X, Y, G)$, one can define $G$ itself to be the function, and in many disciplines in mathematics, this is more useful than the former definition. However, one tradeoff is that, with this definition, the codomain of a function is not unique: as long as you specify the domain of the function, and what elements are associated to what elements, you have uniquely identified the function. The codomain itself does not really matter: the codomain can be chosen to be any superset of $f[X]$, including $f[X]$ itself. In light of this, every function can be said to be surjective, and so it is not meaningful to talk about surjectivity in contexts where this latter definition of a function is being used. Depending on the context, this can be a good thing, or a bad thing.