I use $|a|$ to denote the order of $a$. Take $G, a, b$ as in your question.
Lets first prove:
Claim 1: If $|a| = n$, $|b| = m$, and $n,m$ are coprime, then $|ab| = nm$.
It is clear that $(ab)^{nm} = e$, because $G$ is abelian. Hence, we know that $|ab| \mid nm$.
To show the converse, suppose that $(ab)^k = e$. Then $a^k b^k = e$, so $a^k = b^{-k}$.
Taking both sides to the $m$-th power, we have $a^{mk} = b^{-mk} = (b^m)^{-k} = e$. So $|a| = n$ must divide $mk$. Since $n, m$ are coprime, we must have $n \mid k$.
By a symmetrical argument, we have $m \mid k$. So $nm \mid k$. In particular, $nm \mid |ab|$.
Both these steps imply that $|ab| = nm$. This proves the claim.
From the claim, we see that if $G$ contains two elements $a,b$ with coprime orders $n$ and $m$, we can construct an element with order $nm$; one possible construction would be $ab$.
Now, suppose that $n,m$ are not coprime. We can actually obtain a more 'basic' form of $a$ and $b$. The idea is the fact that if $a$ is an element of order $pq$, then $a^p$ has order $q$. So we can find elements with lower order. The goal is then to start with $a,b$, construct elements $a', b'$ with coprime order, and then take the product $a'b'$.
Let $d = \operatorname{gcd}(n,m)$, and write $n = dN$ and $m = dM$. Then we have that $N,M$ are coprime.
Suppose for simplicity that that $\operatorname{gcd}(M, d) = 1$. Then we can do:
We have
$$
|a| = n = dN, \quad
|b^d| = \frac{m}{d} = M $$
and by the first claim, $(a b^d)$ is an element of order $(dN)M = \operatorname{lcm}(n,m)$.
Now, suppose that neither $\operatorname{gcd}(N,d) = 1$ or $\operatorname{gcd}(M, d) = 1$. This case is a lot harder to describe but the idea is very easy once you understand it.
First, you need to split the gcd $d = d_1 d_2$, such that $\frac{m}{d_1}$ is coprime to $\frac{n}{d_2}$. Let me illustrate this with example. Suppose $n = 2^5 3^2 5^1$ and $m = 3^1 5^2 7^5$. Then the gcd $d = 3^1 5^1$. We can write $d_1 =3, d_2 = 5$, and have $n/d_2 = 2^5 3^2$ is coprime to $m / d_1 = 5^2 y^5$.
With that done, we have
$$
|a^{d_2}| = \frac{n}{d_2}, \quad
|b^{d_1}| = \frac{m}{d_1}, \quad
$$
and
$$
|a^{d_2} b^{d_1}| = \frac{n}{d_2} \cdot \frac{m}{d_1} = \frac{NdMd}{d} = NMd = \operatorname{lcm}(n, m)
$$