This is a theorem in Edwin H. Spanier's Algebraic topology. Page 40. It states that:
If $Q$ is a pointed space such that $\pi_Q$ takes values in the category of groups, then $Q$ is an $H$ cogroup (abelian if $\pi_Q$ takes values in the category of abelian groups).
A proof is not provided in the book. the following is my attempt:
Let $i_1,i_2 \colon Q \to Q \vee Q$ be the natural inclusion. Define $\nu \colon Q \to Q \vee Q$ by $[\nu] = [i_1] \ast [i_2]$ where $\ast$ is the law of composition in the group $[Q,Q \vee Q]$. For any maps $f,g \colon Q \to X$, $(f,g)_{\#} \colon [Q; Q \vee Q] \to [Q;X]$ is a homomorphism $[(f,g) \circ \nu] = (f,g)_{\#} \circ [\nu] = (f,g)_{\#} ([i_1] \ast [i_2]) = ((f,g)_{\#} [i_1]) \ast ((f,g)_{\#}[i_2]) = [f] \ast [g].$ This shows that the multiplication in $[Q;X]$ is induced by the multiplication map $\vee$.
Let $X$ be a one-point space. Then the unique map $Q \to X$ represents the identity element of the group $[Q;X]$, because the unique map $X \to Q$ induces a homomorphism $[Q;X] \to [Q;Q]$. It follows that the composite $Q \to X \to Q$ which is the constant map $c \colon Q \to Q$ represents the identity element of $[Q;Q]$. It follows that $(1_Q,c)\circ \nu \simeq 1_Q$ and $(c,1_Q) \circ \nu \simeq 1_Q$.
To show $\nu$ is homotopy associative, let $j_1,j_2,j_3 \colon Q \to Q \vee Q \vee Q$ be the canonical inclusion. Then
\begin{equation*}
\begin{split}
[(1_Q \vee \nu) \circ \nu] &= (1_Q \vee \nu)_{\#} \circ [\nu] = (1_Q \vee \nu)_{\#} ([i_1] \ast [i_2]) = ((1_Q \vee \nu)_{\#} [i_1]) \ast ((1_Q \vee \nu)_{\#} [i_2])\\ &= [j_1] \ast ([j_2] \ast [j_3])\\
\end{split}
\end{equation*}
Similarly,
\begin{equation*}
\begin{split}
[(\nu \vee 1_Q) \circ \nu] &= (\nu \vee 1_Q)_{\#} \circ [\nu] = (\nu \vee 1_Q)_{\#} ([i_1] \ast [i_2]) = ((\nu \vee 1_Q)_{\#} [i_1]) \ast ((\nu \vee 1_Q)_{\#} [i_2])\\ &= ([j_1] \ast [j_2]) \ast [j_3]\\
\end{split}
\end{equation*}
I think what I got so far is correct but I don't really know how to show $(\nu \vee 1_Q)_{\#} [i_1] = [j_1] \ast [j_2]$ (or $(1_Q \vee \nu )_{\#} [i_2] = [j_2] \ast [j_3]$). Any help would be appreciated.
Also for $f \colon X \to Z$, $g \colon Y \to Z$, $(f,g) \colon (X \vee Y) \to Z$ is defined by $(f,g)(p) = f(p)$ for $p \in X$ and $(f,g)(p) = g(p)$ for $g \in Y$.