Epimorphism in category theory, can be seen as a generalization of "surjective function" in Set.
But we could also have characterized surjective functions in Set as follows:
Definition (*). $f:A\to B$ is surjective if for all $Z$, and all $g:Z\to B$, there is a $g_f:Z\to A$ such that $g=f\circ g_f$.
In Set this definition characterized surjective functions, just as the standard definition for epimorphisms does. But in general categories, this definition is independent from the epimorphism definition (neither implies the other).
Why choose the standard epimorphism definition over (*), or over some other definition that matches in Set, as a generalization of surjective function? What makes the epimorphism definition desirable?
EDIT: Similarly for monomorphism: We can characterize injective functions in Set as:
Definition (&). $f:A\to B$ is injective, if for all $Z$ and all $g:A\to Z$, there is a $g_f:B\to Z$ such that $g=g_f\circ f$.
You definition corresponds to the concept of split epimorphism, which is stronger of that epimorphism.
However, when the category has a projective generator, then epimorphisms can be characterized with a similar concept to being surjective:
Recall that an object $Z$ is a generator if for each pair of distinct parallel morphisms $f,g:X\to Y$ there exists a morphisms $x:Z\to X$ such that $xf\neq xg$. An object $Z$ is projective if and only if for each epimorphism $e:X\to Y$ and each morphism $y:Z\to Y$ there exists a morphism $x:Z\to X$ such that $y=xe$.
This condition is fullfilled, for example:
The only if part follows since $Z$ is projective. For the if part follows arguing by contradiction: if $f$ is not an epimorphism, then there exists a pair of distinct parallel arrows $u,v:Y\to W$ such that $fu=fv$.
Since $Z$ is a generator, there exists $y:Z\to Y$ such that $yu\neq yv$. Let $x:Z\to X$ such that $xf=y$. Then $$yu=xfu=xfv=yv$$ a contradiction.
In that case, epimorphisms are also pullback-stable (see here).