I have seen that the following theorem, known as universal property of the direct sum, is always stated for direct sums of abelian groups:
(Universal mapping property of external direct sum): let $\{G_{s} | s \in S\}$ be a nonempty set of abelian groups, and let $\bigoplus_{s\in S}G_{s}$ be the external direct sum, the associated group homomorphisms being the embedding mappings $i_{s_0} : G_{s_0} → \bigoplus_{s\in S}G_{s}$. If $H$ is any abelian group and $\{\phi_{s} ~\mid~ s \in S\}$ is a system of group homomorphisms $\phi_{s} : G_{s} → H$, then there exists a unique group homomorphism $\phi :\bigoplus_{s\in S}G_{s} → H$ such that $\phi \circ i_{s_0} = \phi_{s_0}$ for all $s_{0}\in S$.
What I do not get is the following: while on one hand the proof of the theorem looks to me not to depend on the commutativity of the family of groups (but I might have missed it), on the other hand it is always stated for direct sums of abelian groups.
Is there an example or a general principle showing what could go wrong if we drop the hypothesis?
Have a nice day!
Let $G_1,G_2$ be two groups. The universal property of their coproduct may be stated as the following
For comparision, the universal property of their product is given by
In both cases the given group homomorphisms factor through the (co)product in one or another way. What makes abelian groups special: for finitely many groups $G_1,\dots, G_n$ their product and coproduct coincide and we call the the defined object their direct sum.
Consider two groups $G_1,G_2$ and their set-theoretic cartesian product (which, by the way, is also the product of two set in the universal sense as above). Define the projection arrows by
$$\pi_1\colon G_1\times G_2\to G_1,~(g_1,g_2)\mapsto g_1,~~~\pi_2\colon G_1\times G_2\to G_2,~(g_1,g_2)\mapsto g_2$$
And for two given maps $f_1\colon H\to G_1$, $f_2\colon H\to G_2$ let $\sigma(x)=(f_1(x),f_2(x))$ for all $x\in H$ which guarentees $\pi_1\circ\sigma=f_1$ and $\pi_2\circ\sigma=f_2$. I leave it to you to show that this morphism is unique as mere set-function. Equip the cartesian product with componentwise composition making it a group. It remains to show that $\sigma$ is then in fact a group homomorphism. For this let $x,y\in H$ and observe
\begin{align*} \sigma(xy)=(f_1(ab),f_2(ab))&=(f_1(a)f_1(b),f_2(a)f_2(b))\\ &=(f_1(a),f_2(a))\circ(f_1(b),f_2(b))\\ &=\sigma(x)\circ\sigma(b) \end{align*}
This argument works out for all groups and thus we can form their categorical product. However, let $G_1,G_2$ be abelian and consider their product (or just cartesian product). Define the inclusion arrows by
$$\iota_1\colon G_1\to G_1\times G_2,~g_1\mapsto(g_1,1),~~~\iota_2\colon G_2\to G_1\times G_2,~g_1\mapsto(1,g_2)$$
Here $(1,1)$ is the identity of $G_1\times G_2$ under componentwise composition. For two given maps $f_1\colon G_1\to H$, $f_2\colon G_2\to H$ let $\sigma(x)=f_1(x)f_2(x)$ for all $x\in G_1\times G_2$. By construction $\sigma\circ\iota_1=f_1$ and $\sigma\circ\iota_2=f_2$ and you can have some fun by showing this map is unique etc. (actually, do it once in set and you are happy for a lifetime). Now, the tricky thing: show that $\sigma$ as defined is a group homomorphism. Let $x,y\in G_1\times G_2$, then
\begin{align*} \sigma(xy)=f_1(xy)f_2(xy)&=[f_1(x)f_1(y)][f_2(x)f_2(y)]\\ &\color{red}=\color{red}{[f_1(x)f_2(x)][f_1(y)f_2(y)]}\\ &=\sigma(x)\sigma(y) \end{align*}
So we can form their categorical coproduct of any two abelian groups just by equpping their product with suitable inclusions. However, note that the crucial transition was to the emphasized line, which would not be possible if not $f_1(y)f_2(x)=f_2(x)f_1(y)$; that is, if $H$ were not abelian.
If we take two arbitrary, possible non-abelian groups we cannot just define $\sigma$ as straightforward as in the abelian case and the internal structure of the free product, i.e. the coproduct, of two groups is different (basically, all becomes more complicated; see here for some explanations).
Here $\mathcal C_2,\mathcal C_3$ are cyclic groups. It is, of course, if we consider $\mathcal C_2,\mathcal C_3$ as abelian groups, but then we would only allow pairs of maps $f_1\colon\mathcal C_2\to H$, $f_2\colon\mathcal C_3\to H$ with $H$ abelian. Dropping this hypothesis, consider $H=S_3$.
You can embed $\mathcal C_2,\mathcal C_3$ into $S_3$ in a canonical way by sending $[1]_2\in\mathcal C_2$ to a transposition and $[1]_3\in\mathcal C_3$ to a $3$-cycle. Take these embeddings $\iota,\overline{\iota}$ and assume $\mathcal C_2\times\mathcal C_3$ is a coproduct. Then there would exist a (unique) group homomorphism $\sigma\colon\mathcal C_2\times\mathcal C_3\to S_3$ making everything commute (i.e. satisfying the universal property from above). You can from here derive that this would imply $\sigma(x,y)=\iota(x)\overline{\iota}(y)=\overline{\iota}(x)\iota(y)$ for all $x\in\mathcal C_2,y\in\mathcal C_3$; take $x=[1]_2$ and $y=[1]_3$ and derive a contradiction (two commuting elements in $S_3$ which do not commute as it can be verified by computation). Thus, the direct product $\mathcal C_2\times\mathcal C_3$ of $\mathcal C_2,\mathcal C_3$ is not their coproduct.
The free product of $\mathcal C_2,\mathcal C_3$ can be constructed by taking two generators $x,y$ and force them to fulfill $x^2=1,y^3=1$ only. This group consists of all 'words' of the form $xy^2yxy^2x$ etc. and, as I said, is a little bit more chaotic if you want.
This is exercise ${\rm II}.3.5$ in P. Aluffi's: Algebra Chapter 0 and the idead of the proof is taken from these notes
The concepts of product and coproduct can be generalized to arbitary categories by just appealing to the universal properties given. Looking the other way around: we can view the direct sum (or the direct product, or the disjoing union, etc. pp.) as particular objects with particular desirable properties defined by the respective universal properties; not as objects which happen to satisfy such and such a property.
We define the direct sum (the direct product, the disjoint union) such that they do exactly what we want; and what we want is encoded in the universal property. Maybe this helps to gain some intuition.