Like the title said, I want to ask why does it fail. The claim and the counterexample here https://ipfs.io/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Splitting_lemma.html are very convincing. But what would be wrong with the proof?
Let
$$0\to A \to B \to C \to 0$$
be a short exact sequence of nonabelian groups. Let $f:A\to B$ and $g:B\to C$ be the maps. Assume there exists $h:C\to B$ s.t. $gh=Id_C$. I will prove that $B=A\oplus C$.
It is routine check to show that $B=Ker(g)\oplus Im(h)$ by setting $b=b-hg(b)+hg(b)$.
I even checked it manually with $A=A_3, B=S_3$ and $C=C_2$ in which $A_3$ is the alternating group, $S_3$ is the symmetry group and $C_2$ is a cyclic group. Of course, $B$ is nonabelian while $A\oplus C$ is abelian, hence this proof is definitely wrong.
However, I cannot see a flaw in the proof? Can you show me? THanks
What fails here is that nonabelian groups are not an abelian category. The key requirement that fails is that the hom-sets are not abelian groups (we cannot subtract and add morphisms). Note that the category of groups satisfies all the axioms of an abelian category except that monos are not necessarily normal; if it "did" satisfy this axiom, then we "could" construct abelian group structures on the hom sets, which is essential in the proof of the splitting lemma.
Indeed, for morphisms $f, g : A \rightarrow B$ of abelian groups $A$ and $B$, we can form $f + g$ and $-f$, defined where $(f+g)(x) = f(x) + g(x)$ and $(-f)(x) = -f(x)$. But, if $A$ and $B$ are not abelian, then how would one say $(f+g)(x+y) = (f+g)(x) + (f+g)(y)$?
$$(f + g)(x+y) = f(x +y) + g(x + y) = f(x) + f(y) + g(x) + g(y) \stackrel{\text{!?}}{=} f(x) + g(x) + f(y) + g(y) = (f+g)(x) + (f+g)(y) $$
Similar problems occur with $-f(x)$.
Let's go through the proof of this and see where it fails. Take a short exact sequence of abelian groups $0 \rightarrow A \stackrel{\iota}{\rightarrow} B \stackrel{\pi}{\rightarrow} C \rightarrow 0$ with a section $\sigma : C \rightarrow B$. Key step: take the morphism $\tau = 1_B - \sigma \pi$. We can subtract maps of abelian groups, but this relies on commutativity. $\pi \circ \tau = \pi \circ (1_B - \sigma \pi) = \pi - \pi \sigma \pi = \pi - \pi = 0$, so that $\tau$ factors through the kernel $\iota$ of $\pi$ by a map $\upsilon : B \rightarrow A$. This map is a rectract of $\iota$; $\iota (\upsilon \iota - 1_A) = \iota \upsilon \iota - \iota = \tau \iota - \iota = (1_B - \sigma \pi) \iota - \iota = \iota - \iota = 0$.
What happens instead is that we often have a section for $0 \rightarrow A \rightarrow B \rightarrow C \rightarrow 0$ without a retract. When $A$ is normal in $B$ and a section exists, we get a semidirect product (in fact, the two are equivalent). So semidirect products are a whole class for you to investigate.
For instance, $\mathbb{Z} / 2 \mathbb{Z}$ acts on any abelian group $A$ where the nontrivial map sends $a$ to $-a$. This gives a nonabelian semidirect product $A \rtimes \mathbb{Z} / 2 \mathbb{Z}$. Explicitly, that's $A \times \mathbb{Z} / 2 \mathbb{Z}$ as a set with multiplication $(a, \overline{1}) (a', \overline{n})= (a - a', \overline{1} + \overline{n})$. Since it's nonabelian, we can't have both a section and a retract, which would result in a direct product of abelian groups, which would be abelian.
Edit: See below, Arnaud appears to be correct about epimorphisms. I have changed the answer accordingly.