Morphisms to products and morphisms from coproducts
Both maps are the result of $\mathsf{Grp}$ having a "zero object" (the trivial group). A zero object is an object $\mathbf{Z}$ which is both initial and final in the category; that is, for every object $C$, there is a unique morphism $i_C\colon \mathbf{Z}\to C$, and a unique morphism $t_C\colon C\to\mathbf{Z}$.
This means that for any two objects $C_1$ and $C_2$, there is a canonical "zero map", $z_{C_1,C_2}\colon C_1\to C_2$, obtained via the composition $i_{C_2}\circ t_{C_1}\colon C_1\to \mathbf{Z}\to C_2$.
-
In any category with a zero object, if $A$ and $B$ have a product $P$, then there are canonical morphisms $\iota_A\colon A\to P$ and $\iota_B\colon B\to P$, obtained by considering the maps $\mathrm{id}_A\colon A\to A$ and $z_{A,B}\colon A\to B$, to get a map $A\to P$ via the universal property; and symmetrically for $B$. Since $\pi_A\circ \iota_A = \mathrm{id}_A$, it follows that $\iota_A$ has a left inverse and therefore is a monomorphism (and also you can conclude that the projection map $\pi_A$ is an epimorphism); symmetrically for $\iota_B$. The same holds for a product over an arbitrary family, not just a pair of objects.
-
Dually, in any category with a zero object, if $A$ and $B$ have a coproduct $C$, with canonical morphisms $\iota_A,\iota_B$, you get maps $p_A\colon C\to A$ and $p_B\colon C\to B$ obtained by considering the maps $\mathrm{id}_A\colon A\to A$ and $z_{B,A}\colon B\to A$ to obtain the map $p_A$; since $p_A\circ \iota_A = \mathrm{id}_A$, we conclude that $p_A$ has a right inverse and thus is an epimorphism (and $\iota_A$ is a monomorphism). Symmetrically for $B$, and for an arbitrary family that has a coproduct in the category.
Since the trivial group gives you a zero object for $\mathsf{Grp}$, you can observe that phenomenon. In $\mathsf{Set}$, the empty set is the initial object, and singletons are terminal objects, but the lack of a zero object means that you do not observe the same phenomenon. You have the same problem in $\mathsf{Semigroup}$ and in $\mathsf{Ring}^1$ (rings with unity with unital morphisms), but in $\mathsf{Monoid}$ and in $\mathsf{AbGrp}$, the zero object gives you the same phenomenon. In the category $\mathsf{Set}_*$ of pointed sets, singletons are (isomorphic) zero objects, so again you get the same phenomenon thanks to the corresponding zero morphisms.