It's rather beautiful that product and coproduct (sum) coinsides in the category of Abelian groups. Recall that product object is a universal construct which satisfies a spectial pattern:

Given two groups $A, B$, there can be constructed a product object $A \times B$ with two projections $p$ and $q$ so that $p(a, b) = a$ and $q(a, b) = b$.

The product must satisfy a universal property which can be demostrated as the following commutative graph:

Accroding to above graph, given any group $X$ with projections:

$f: X \rightarrow A$ and $g: X \rightarrow B$

there exists unique homomorphism $h: X \rightarrow A \times B$ satisfying

$p \circ h = f$ and $q \circ h = g$.

Apparently, $h$ can be defined as:

$h(x) = (f(x), g(x))$

Now, let's prove that the product constructed above is also a coproduct is all groups are abelian.

First of all, we define two injections:

$i: A \rightarrow A \times B,\ i(a) = (a, 0)$

$j: B \rightarrow A \times B,\ j(b) = (b, 0)$

Given other injections:

$f: A \rightarrow X$ and $g: B \rightarrow X$,

We need to find a unique morphism $h: A \times B \rightarrow X$ so that

$h \circ i = f$ and $h \circ j = g$

Fortunately, $h$ can be defined as

$h(a, b) = f(a) + g(b)$

It's easy to verify that $h$ is a homomorphism:

$h(a_1​,b_1​)+h(a_2​,b_2​)$
$= f(a_1​)+g(b_1​)+f(a_2​)+g(b_2​)$
$= f(a_1​+a_2​)+g(b_1​+b_2​)$
$= h((a_1​,b_1​)+(a_2​,b_2​))$

and

$h \circ i​(a) = h(a,0) = f(a)$

$h \circ j​(b) = h(0,b) = g(b)$