characterisation of direct sum of abelian groups The direct sum of abelian groups can be defined in several equivalent ways, but I have some problem proving the equivalence.

Definition 1:
Given abelian groups $A$ and $B$, the direct sum is defined as the castesian product $A \times B$, equipped with the operation $(a,b)(a',b') = (aa',bb')$. Then $A$ can be identified as the subgroup $A \times \lbrace e_B \rbrace$ in $A \times B$. The case for $B$ similar.

Definition 2:
Let $A$ and $B$ be subgroups of an abelian group $G$. $G$ is said to be the direct product of $A$ and $B$ iff every element $g \in G$  can be expressed uniquely as $g = a + b$, with $a \in A$ and $b \in B$.

However, I have difficulty proving the following: i.e. if [EDIT: additional assumption: A and B are subgroups of an abelian group G and] $G \cong A \times B$  as defined in definition 1, then every element $g \in G$ can be expressed uniquely as $g = a + b$, with $a \in A$ and $b \in B$. Given only an isomorphism $\phi: A \times B \rightarrow G$, I can only conclude that $g = \phi(a,e_B) + \phi(e_A,b)$, but I do not know whether $\phi(a,e_B) = a$ and $\phi(e_A,b) = b$. I know they almost look the same, and should not matter much in the spirit of 'up to isomorphism', but I still cannot see how I can proceed to show $g = a + b$.

Can anyone help me proceed? Thank you very much.
Related to last comment:

But then there is no much problem imo, either: in the cartesian product every pair $\;(a,b)\;$ is unique, meaning: $\;(a,b)=(a',b')\iff a=a'\,,\,\,b=b'\;$ , so if $\;\phi:A\times B\to G\;$ is a group isomorphism, then if $\;\phi(a,1_B)=g_A\;,\;\;\phi(1_A,b)=g_B\;$ , we have then $\;g=g_Ag_B\in G\;$, and this expression is unique, no matter where $\;A\times 1_B\,,\,\,1_A\times B\;$ are mapped to by $\;\phi\;$ .

Also, observe that $\;A\times1_B\cong A\;,\;\;1_A\times B\cong B\;$ and this is as much as we can say in this respect.
Related to last comment:

But then there is no much problem imo, either: in the cartesian product every pair $\;(a,b)\;$ is unique, meaning: $\;(a,b)=(a',b')\iff a=a'\,,\,\,b=b'\;$ , so if $\;\phi:A\times B\to G\;$ is a group isomorphism, then if $\;\phi(a,1_B)=g_A\;,\;\;\phi(1_A,b)=g_B\;$ , we have then $\;g=g_Ag_B\in G\;$, and this expression is unique, no matter where $\;A\times 1_B\,,\,\,1_A\times B\;$ are mapped to by $\;\phi\;$ .

Also, observe that $\;A\times1_B\cong A\;,\;\;1_A\times B\cong B\;$ and this is as much as we can say in this respect.