Let $G=\mathbb{Z}_n \times \mathbb{Z}_m$ and $d=p^k$ for some prime $p$ such that $d$ divides both $n$ and $m$. Then $G$ has exactly $d\phi(d)+[d-\phi(d)]\phi(d)$.
For example consider the group $G=\mathbb{Z}_4 \times \mathbb{Z}_4$ here $d=p^k$ is $4=2^2$ and $4$ divides $n=4$ and $m=4$ so using above formula we have there are $12$ elements of order $4$.
If we have a group $G$ such as $G=\mathbb{Z}_{12}\times \mathbb{Z}_2$, then $G$ has $6$ elements of order $6$ and the group $G=\mathbb{Z}_6 \times \mathbb{Z}_6$ has $24$ elements of order $6$.
Is there any formula for counting number of elements of a specific order in later two groups?