I'm studying the free product of two groups $A$ and $B$. In order to show that there is a unique free product, one considers the following:
Suppose that $G, X$ are two free products of $A$ and $B$. Then we have unique(!) homomorphisms $\psi: G \to X$ and $\phi: X \to G$ making the usual diagram commute. There we conclude that as both $\psi\circ\phi\circ\psi$ and $\psi$ are homomorphisms $G \to X$, we get $\psi\circ\phi = \mathrm{Id}_G$. Similarly $\phi\circ\psi = \mathrm{Id}_X$.
I was wondering if one can generalize this argument: Let $C$ be a category and $G,X$ objects such that there exist unique morphisms $f: G \to X$ and $g: X \to G$. Is it true that if we take $\alpha \in \mathrm{Hom}(G,G)$ it follows that $\alpha = \mathrm{Id}_G$?
So obviously, both $f\circ\alpha$ and $f$ are in $\mathrm{Hom}(G,X)$, which means $f\circ\alpha = f$. Can one conclude from here that $\alpha = \mathrm{Id}$?
I can finish the argument if one considers the category of sets or groups, but I don't see the general argument using the axioms of category theory.
No, it would not necessarily be true that $\alpha=id_G$. For example, if $X$ is the trivial group $\{1\}$, then there are unique morphisms of groups $G\to X$ and $X\to G$, but if $G$ itself has more than one element there is always at least one non-identity morphism $\alpha$ in $\operatorname{Hom}(G,G)$, since you can simply take the trivial morphism, defined by $\alpha(g)=1_G$ for all $g\in G$.