Motivation behind the definition of monomorphism and epimorphism in category theory Let $\mathcal{C}$ be a (locally small) category and let $X$ and $X'$ be objects in $\mathcal{C}$. 


*

*(Definition $1$) We say that $f\colon X\to X'$ is a monomorphism if for any object $Y$ in $\mathcal{C}$, the map 
$$\operatorname{Hom}(Y, X)\to \operatorname{Hom}(Y, X')$$
given by $g\mapsto f\circ g$ is a one-to-one function. 

*(Definition $1'$) We say that $f\colon X\to X'$ is a monomorphism if there exists $g\colon X'\to X$ such that $g\circ f=\operatorname{Id}_X$.
Of course both definitions generalize one-to-one functions in the category of sets, but Definition $1$ is the one which is used in the literature. However I want to know why my definition, namely Definition $1'$, is not as useful as the first one to be adopted as the standard way of defining monomorphisms. As a related question, is there any relation between the two versions? Does one definition imply the other one?
My own guess is Definition $1$ is chosen because of Yoneda's lemma.
Similarly one can give the following definitions for an epimorphism:


*

*(Definition $1$) We say that $f\colon X\to X'$ is an epimorphism if for any object $Y$ in $\mathcal{C}$, the map 
$$\operatorname{Hom}(X',Y)\to \operatorname{Hom}(X, Y)$$
given by $g\mapsto g\circ f$ is a one-to-one function. 

*(Definition $1'$) We say that $f\colon X\to X'$ is an epimorphism if there exists $g\colon X'\to X$ such that $f\circ g=\operatorname{Id}_{X'}$.

*(Definition $1''$) We say that $f\colon X\to X'$ is an epimorphism if for any object $Y$ in $\mathcal{C}$, the map 
$$\operatorname{Hom}(Y, X)\to \operatorname{Hom}(Y, X')$$
given by $g\mapsto f\circ g$ is an onto function. 
My questions are similar to the case of monomorphism of categories. My guess is that a reason for choosing Definition $1$ as the "right" definition of an epimorphism is "duality."
Any answers or comments are highly appreciated.
Edit I thought it might be a good idea to include two possible ways of defining an isomorphism in order to compare them.


*

*(Definition $1$) We say that $f\colon X\to X'$ is an isomorphism if there exists $g\colon X'\to X$ such that $f\circ g=\operatorname{Id}_{X'}$ and $g\circ f=\operatorname{Id}_X$.

*(Definition $1'$) We say that $f\colon X\to X'$ is an isomorphism if it is both a monomorphism (in the sense of Definition $1$) and an epimorphism (as in Definition $1$). 
 A: If in a category $r\circ s={\rm id}$ then $r$ is by definition a
retraction and $s$ is by definition a section. So somehow you are
wondering: is monomorphism the same concept as section and is epimorphism
the same concept as retraction? In category $\textbf{Set}$ where monomorphisms
can be described as injective functions and epimorphisms as surjective
functions it is indeed true that a function is surjective iff it is
a retraction, but it is not true that a function is injective iff
it is a section. The 'spoilers' are functions $f:\emptyset\rightarrow X'$
where $X'\neq\emptyset$. They are (vacuously) injective but no function $g:X'\rightarrow\emptyset$
exist. In general sections are special monomorphisms and retractions are special epimorphisms (see the comment of Najib on this answer). Often there are classes that are 'in between'. There is much more to say on this subject, but I am not really
an expert and think that there are people on this site who can do
much better. This is only showing you one obstacle.
A: Monomorphisms are defined the way they are because that is what works in many concrete categories of interest: $\mathbf{Set}$, $\mathbf{Grp}$, $\mathbf{Ring}$, etc. Even $\mathbf{Top}$ is an example if you expect monomorphisms to be injective continuous maps (as opposed to, say, topological embeddings). Moreover, with this definition, the Yoneda embedding sends monomorphisms to componentwise injective natural transformations, which is  as much as what one can hope for.
By constrast, epimorphisms are defined the way they are because we want duality. It is true that epimorphisms in $\mathbf{Set}$ are surjections. It is also true in some concrete categories like $\mathbf{Ab}$ and $\mathbf{Top}$, but it is not true in other concrete categories: for instance, in the category of Hausdorff spaces and continuous maps, the epimorphisms are precisely the continuous maps with dense image.
I should also mention that a morphism is a split epimorphism if and only if the Yoneda embedding sends it to a componentwise surjective natural transformation. Indeed, the "only if" direction is clear, and if $f : A \to B$ is a morphism such that 
$$\mathrm{Hom}(T, f) : \mathrm{Hom}(T, A) \to \mathrm{Hom}(T, B)$$
is surjective for every $T$, then taking $T = B$, we find there is a morphism $s : B \to A$ such that $f \circ s = \mathrm{id}_B$, as claimed.

Addendum. There are categories in which morphisms that are simultaneously monomorphisms and epimorphisms are not necessarily isomorphisms. The easiest example is $\mathbf{Top}$: a continuous map that is both injective and surjective is not necessarily a homeomorphism.
