Order of elements is lcm-closed in abelian groups
Let $n = \prod_i p_i^{n_i}$ and $m = \prod_i p_i^{m_i}$, where the $p_i$s are the same. Thus $\mathrm{lcm}(n,m) = \prod_i p_i^{\max(n_i,m_i)}$. Let $N = \{ i : n_i \geq m_i \}$ and $M = \{ i : n_i < m_i \}$. Define $n' = \prod_{i \in N} p_i^{n_i}$ and $m' = \prod_{i \in M} p_i^{m_i}$. Now $a' = a^{n/n'}$ is of order $n'$, and $b' = b^{m/m'}$ is of order $m'$. Since $n',m'$ are coprime, we know that there is an element of order $n'm' = \mathrm{lcm}(n,m)$.
You can also prove it using the structure theorem for abelian groups, but that's an overkill.
Below is a simple inductive proof excerpted from my post in a prior thread.
Lemma $\ $ A finite abelian group $\rm\,G\,$ has lcm-closed order set, i.e. with $\rm\, o(X) := $ order of $\rm\: X$
$$\rm X,Y \in G\ \ \Rightarrow\ \ \exists\ Z \in G\!:\ o(Z) = lcm(o(X),o(Y))\qquad\ \ \ \ \ $$
Proof $\ \ $ We induct on $\rm\, o(X)\, o(Y).\, $ If it's $\,1\,$ let $\rm\:Z = 1.\:$ Else split off $\rm\,p's$ in $\rm\,o(X),\,o(Y),\,$ i.e.
write $\rm\ \ o(X)\, =\, AP,\: \ \ o(Y) = B\bar P,\, $ prime $\rm\: p\nmid A,B,\, $ wlog $\rm\,p\,$ $\rm\color{#0a0}{highest}$ in $\,\rm P\,$ so $\,\rm\color{#0a0}{\bar P\!\mid P}\! =\! p^{\large k} > 1 $
Then $\rm\: o(X^{\large P}) = A,\ \ o(Y^{\large \bar P}) = B.\ $ By induction $\rm\, \exists\, Z\!:\ o(Z) = lcm(A,B)$
so $\rm\,\ \ o(X^{\large A}\,\!Z) =\, P\, lcm(A,B) = lcm(AP,B\bar P) = lcm(o(X),o(Y))\,\ $ by here.
Note $ $ This is an element-wise form of what's known as "Herstein's hardest problem": $2.5.11$, p. $41$ in the first edition of Herstein's popular textbook Topics in Algebra. In the 2nd edition Herstein added the following note (problem $2.5.26$, p. $48$)
Don't be discouraged if you don't get this problem with what you know of group theory up to this stage. I don't know anybody, including myself, who has done it subject to the restriction of using material developed so far in the text. But it is fun to try. I've had more correspondence about this problem than about any other point in the whole book."
Both responses you have received provide correct answers. In fact, you don't need to go so far as to obtain elements of relatively prime orders; all you need to worry about are primes with the property that they divide $nm$, and the largest power of $p$ that divides $n$ is equal to the largest power of $p$ that divides $m$.
Lemma. Let $x$ and $y$ be commuting elements of a group $G$, and assume $x$ and $y$ are of finite orders $n$ and $m$, respectively. Suppose that for every prime $p$ that divides $nm$, the largest power of $p$ that divides $n$ is different from the largest power of $p$ that divides $m$. Then the order of $xy$ in $G$ is $\mathrm{lcm}(n,m)$.
Proof. Let $\ell=\mathrm{lcm}(n,m)$. It is easy to verify that $(xy)^{\ell}=1$, so we just need to show that $\ell$ is the smallest positive integer $k$ such that $(xy)^k=1$. Suppose that $(xy)^k = 1$, with $0\lt k\leq \ell$.
Since $(xy)^k = x^ky^k = 1$, then $x^k = y^{-k}$, and in particular $x^k$ has the same order as $y^k$. The order of $x^k$ is $n/\gcd(n,k)$, and the order of $y^k$ is $m/\gcd(m,k)$. Let $p$ be a prime that divides $\ell$, and let $a=\mathrm{ord}_p(n)$, $b=\mathrm{ord}_p(m)$, and $c=\mathrm{ord}_p(k)$. Assume $b\lt a$. If $c\lt a$, then $\mathrm{ord}_p(n/\gcd(n,k)) = a-c$, and $\mathrm{ord}_p(m/\gcd(m,k))=\max(0,b-c)\lt a-c$, which is impossible. Thus, $c=a$. A symmetric argument shows that if $a\lt b$, then $c=b$. That is, for all primes $p$ that divide $\ell$, we have $\mathrm{ord}_p(k) = \max(\mathrm{ord}_p(n),\mathrm{ord}_p(n)) = \mathrm{ord}_p(\ell)$. Hence $k=\ell$. QED
So now assume that $a$ is an element of order $n$ in an abelian group, and let $b$ be an element of order $m$. Let $p_1,\ldots,p_k$ be the primes that divide $nm$ and for which the $p$-order of $p_i$ in $m$ and in $n$ are equal. Then $$\mathrm{lcm}(n,m) = \mathrm{lcm}\left(n, \frac{m}{p_1\cdots p_k}\right).$$ Since $m/(p_1\cdots p_k)$ is the order of $b^{p_1\cdots p_k}$, then it follows from the lemma that $ab^{p_1\cdots p_k}$ has order $\mathrm{lcm}(n,m)$, as desired.