Let $a^n, a^m \in (a^k)$ for some positive integer $k$. Then $k \mid n, m.$ Hence $k \mid \operatorname{gcd(n, m)}$.
How is it possible? Let $k = 6, n = 12, m =24.$
Context:
Let $H$ be the smallest subgroup of $(a)$ s.t. $a^n, a^m \in H$. Prove that $H = (a^{\operatorname{gcd(n, m)}}).$
Proof: Since $G$ is cyclic, $H$ is cyclic. Hence $H = (a^k)$ for some $k \in \mathbb N.$ Since $a^n, a^m \in H,$ then $k \mid n,m.$ Hence $k \mid \operatorname{gcd(n, m)}.$ Thus $a^{\operatorname{gcd(n, m)}} \in H.$ Hence $(a^{\operatorname{gcd(n, m)}}) \subset H.$ Also, since $a^{\operatorname{gcd(n, m)}} \mid n, m$ then $a^n, a^m \in (a^{\operatorname{gcd(n, m)}})$. Since $H$ is the smallest subgroup of $(a)$ containing $a^n, a^m$ and $a^n, a^m \in (a^{\operatorname{gcd(n, m)}})$, we conclude that $H = (a^{\operatorname{gcd(n, m)}}).$