Proof Verification - Hungerford I.8.3 
$\textbf{Hungerford I $\S$8, problem 3.}$ Let $G$ be an (additive) abelian group with subgroups $H$ and $K$. Show that $G \cong H \oplus K$ iff there are homomorphisms $\pi_1:G\to H$, $\pi_2:G\to K$, $\iota_1: H\to G$, and $\iota_2:K\to G$ such that $$\pi_1\iota_1 = 1_H,\ \pi_2\iota_2 = 1_K,\ \pi_1\iota_2 = 0 = \pi_2\iota_1$$ and $\iota_1\pi_1(x) + \iota_2\pi_2(x) = x$ for all $x \in G$.

My question is if the abelian assumption is needed at all.
Here is a purposed proof of the $\Longleftarrow$ direction that does not use the fact that $G$ is abelian whatsoever:

Consider $f :G \to H \oplus K$ with $f(g) := (\pi_1(g), \pi_2(g))$ for all $g\in G$. Then $f$ is a homomorphism; $f$ is surjective since if $(h,k)\in H \oplus K$, then by taking $g = \iota_1(h)\iota_2(k)$, our assumption gives that $f(g) = (h,k)$; and $f$ is injective since if $g,g'\in G$ and $f(g) = f(g')$, then $\pi_1(g) = \pi_1(g')$ and $\pi_2(g) = \pi_2(g')$ which (again by our assumption) yields that $$g = \iota_1(\pi_1(g)) \cdot \iota_2(\pi_2(g)) = \iota_1(\pi_1(g'))\cdot \iota_2(\pi_2(g')) = g'.$$

The other direction is somewhat obvious and I don't think uses the fact that $G$ is abelian at all either:

Let $\phi: G\to H \oplus K$ be an isomorphism and for $i = 1,2$ let $\pi_i := p_i\phi$ and $\iota_i:=\phi^{-1}j_i$, where $p_i$ and $j_i$ are canonical projections/inclusions.

Yes, there is another post about this question but focuses on generalizing this problem in a completely different way and thus does not answer my question.
 A: I think your argument works. As I note above, the main issue I would have with the statement itself, if we do not assume $G$ is abelian, is that the function
$$x \longmapsto \iota_1\pi_1(x)\iota_2\pi_2(x)\tag{1}$$
is not known to be a group homomorphism. If $A$ is abelian, and $f,g\colon G\to A$ are group morphisms, then the pointwise product/sum of $f$ and $g$ is a homomorphism, since
$$\begin{align*}
(f+g)(xy) &= f(xy)+g(xy)\\ 
&= f(x)+f(y)+g(x)+g(y)\\
 &= f(x)+g(x)+f(y)+g(y)\\
 &= (f+g)(x) + (f+g)(y).
\end{align*}$$
But if the target is not abelian, and the image of $f$ and $g$ are not known to commute element-wise, then we don't know whether $f+g$ is a homomorphism. So we would have to interpret the final assertion as a statement that the map of underlying sets given in $(1)$ equals the identity map, emphasizing that we are not asserting, a priori, that the map is a homomorphism. You don't use the fact that this map is a homomorphism, so you are fine.
We can avoid this issue by replacing the assertion that the map $(1)$ is equal to the identity map with the assertion that $\ker(\pi_1)\cap\ker(\pi_2)=\{e\}$, which makes sense whether $G$ is abelian or not. This eqality follows from the assertion that the map $(1)$ is equal to the identity, since if $x\in\ker(\pi_1)\cap\ker(\pi_2)$, then $(1)$ imlies that $x=e$.
That said, you are correct that the conclusion also holds for nonabelian groups, even with the weaker assertion about the kernels.
From the fact that we have $\pi_i\iota_i$ be the identity we know that $\pi_i$ is surjective and $\iota_i$ is injecive. We also know that we can express $G$ as semidirect products, $G=\ker(\pi_1)\rtimes \iota_1(H)$, and $G= \ker(\pi_2)\rtimes\iota_2(K)$. The semidirect products are direct products if and only if $\iota_1(H)$ and $\iota_2(K)$ are also normal.
From the fact that $\pi_2\iota_1$ and $\pi_1\iota_2$ are the trivial maps we know that $\iota_1(H)\subseteq \ker(\pi_2)$ and $\iota_2(K)\subseteq \ker(\pi_1)$. So it suffices to show that $\iota_2(K)=\ker(\pi_1)$ (the argument is clearly symmetric in $H$ and $K$).
Let $x\in\ker(\pi_1)$. Then $x(\iota_2\pi_2(x))^{-1}\in \ker(\pi_1)$, since $\iota_2(K)\subseteq\ker(\pi_1)$. Applying $\pi_2$ to this product, we get
$$\begin{align*}
\pi_2\left( x\bigl(\iota_2\pi_2(x)\bigr)^{-1}\right) &= \pi_2(x)\left(\pi_2\iota_2\pi_2(x)\right)^{-1}\\
&= \pi_2(x) \left(\pi_2(x)\right)^{-1} \\
&= e,
\end{align*}$$
with the next-to-last equality because $\pi_2\iota_2$ is the identity map. Thus, $x(\iota_2\pi_2(x))^{-1}\in\ker(\pi_1)\cap\ker(\pi_2)$, so it is the identity element, and hence $ x = \iota_2\pi_2(x)$, proving that $\ker(\pi_1)\subseteq \iota_2(K)$, giving equality.
Since $\iota_2(K)$ and $\ker(\pi_1)$ are both normal, and $G= \ker(\pi_1)\rtimes \iota_2(K)$, it follows that $G= \ker(\pi_1)\times\iota_2(K)$. And from a symmetric argument we also get that $\ker(\pi_2)=\iota_1(H)$, yielding $G=\iota_1(H)\times\iota_2(K)$. Since the $\iota_j$ are embeddings, this gives $G\cong H\times K$, as desired.
