Let $G$ be a group. What is ${\rm Hom}(\mathbb{Z}_n \times \mathbb{Z}_m, G)$? $\DeclareMathOperator{\Hom}{Hom}$

Let $G$ be a group. What is $\Hom(\mathbb{Z}_n \times \mathbb{Z}_m, G)$?

I think that $$\Hom(\mathbb{Z}_n \times \mathbb{Z}_m, G) = \{\phi_{a,b} : a, b \in G, a^n = e,b^m = e\},$$ where $\phi_{a,b}(k,l ) = a^k b^l$ for $(k,l)\in\mathbb{Z}_n\times \mathbb{Z}_m.$
By definition, $\Hom(\mathbb{Z}_n \times \mathbb{Z}_m, G)$ is the set of homomorphisms from $\mathbb{Z}_n \times \mathbb{Z}_m$ to $G.$ Let $\phi\in \Hom(\mathbb{Z}_n \times \mathbb{Z}_m, G)$ and $a = \phi((1,0)).$ Let $b = \phi((0,1)).$ Then for all $(k,l)\in \mathbb{Z}_n \times \mathbb{Z}_m, \phi((k,l)) = \phi(k(1,0) + l(0,1)) = \phi(k(1,0))\phi(l(0,1)) = a^k b^l$ so that $\phi = \phi_{a,b}$ and $a^n = \phi((n,0)) = \phi((0,0)) = e$.
Similarly, $b^m = e.$ The map $\phi_{a,b}$ is also well-defined because if $k\equiv l \mod n$ and $p\equiv q \mod m,$ then $a^k = a^l$ and $b^p = b^q.$ Also, $\phi_{a,b}$ is a homomorphism because $a^{k_1 + k_2} b^{l_1 + l_2} = (a^{k_1} b^{l_1})(a^{k_2}b^{l_2})$. Thus, $\Hom(\mathbb{Z}_n \times \mathbb{Z}_m, G) = \{\phi_{a,b} : a, b \in G, a^n = e,b^m = e\},$ where $\phi_{a,b}(k,l ) = a^k b^l$ for $(k,l)\in\mathbb{Z}_n\times \mathbb{Z}_m.$

Is this correct?

 A: Here is the general result:
Theorem. Let $H$ and $K$ be groups, and let $G$ be a group. Then the morphism $H\times K\to G$ are in one-to-one correspondence with pairs $(f,g)$, where $f\colon H\to G$ and $g\colon K\to G$ are group homomorphisms, and $f(H)\subseteq C_G(g(K))$ (equivalently, $g(K)\subseteq C_G(f(H))$.
Proof. First, let us note that if $f(H)\subseteq C_G(g(K))$, then each $f(h)$ commutes with each $g(k)$, and hence each $g(k)$ lies in $C_G(f(H))$. Thus, the conditions $f(G)\subseteq C_G(g(K))$ and $g(K)\subseteq C_G(f(H))$ are indeed equivalent. (Alternatively, $f(H)\subseteq C_G(g(K))$ implies $C_G(f(H))\supseteq C_G(C_G(g(K)))\supseteq C_G(g(K))$.)
Let $\varphi\colon H\times K\to G$ be a group morphism. Identify $H$ with $H\times\{e\}$ and $K$ with $\{e\}\times K$ in $H\times K$. We define $f=\varphi|_{H\times\{e\}}$ and $g=\varphi|_{\{e\}\times K}$, identifying $H$. Note that since $H\times\{e\}$ and $\{e\}\times K$ generate $H\times K$, the two restrictions uniquely determine $\varphi$, so the association is one-to-one from maps on $H\times K$ to pairs.
To verify that $f(H)\subseteq C_G(g(K))$, let $h\in H$ and $k\in K$. Then $$f(h)g(k) = \varphi(h,e)\varphi(e,k) = \varphi(h,k) = \varphi( (e,k)(h,e)) = \varphi(e,k)\varphi(h,e) = g(k)f(h).$$ Thus, every element of $f(H)$ commutes with every element of $g(K)$, as required.
Conversely, given $f\colon H\to G$ and $g\colon K\to G$ with $f(H)\subseteq C_G(g(K))$, define $\varphi\colon H\times K\to G$ by $\varphi(h,k) = f(h)g(k)$. To verify this is a group homomorphism, we have
$$\begin{align*}
\varphi(h_1,g_1)\varphi(h_2,g_2) &=f(h_1)g(k_1)f(h_2)g(k_2)\\
&=f(h_1)f(h_2)g(k_1)g(k_2) &\text{(since }f(h_2)\text{ commutes with }g(k_1)\text{)}\\
&= f(h_1h_2) g(k_1k_2)\\
&= \varphi(h_1h_2,k_1k_2)\\
&= \varphi\Bigl( (h_1,k_1)(h_2,k_2)\Bigr).
\end{align*}$$
Now note that the pair associated to this map are the original $f$ and $g$, showing that the association is also surjective and giving the correspondence. $\Box$
Now, to complete what you want, we have:
Theorem. Let $G$ be a group, $n\gt 0$. The morphism $\mathbb{Z}/n\mathbb{Z}\to G$ are in one-to-one correspondence with elements $g\in G$ such that $g^n=e$.
Proof. If $f\colon\mathbb{Z}/n\mathbb{Z}\to G$ is a morphism, then $f(1)=g$ satisfies $g^n = f(n) = f(0) = e$. Conversely, if $g\in G$ has exponent $n$, then the map $f\colon\mathbb{Z}/n\mathbb{Z}\to G$ given by $f(\overline{a}) = g^a$ is easily verified to be a well-defined group homomorphisms. The two associations are inverses of each other. $\Box$
Putting the two together we see that your result is only missing one detail, as indicated by Lukas Heger in the comments: that your elements $a$ and $b$ should centralize each other, i.e., commute.
