Let $(G,*)$ be a group and $a \in G$. Suppose that $|a|=n$ and $n=mk$ for some positive integers $m$ and $k$. What is $|a^k|$?
attempt: Let $a \in G$ such that $|a|=n$. Then, \begin{equation*} a^n = a^{mk} = (a^k)^m = e_G \end{equation*} where $e_G$ is the identity element of $G$. Thus, the order of $a^k$ is $m$.
In particularly, by theorem: Let $(G,*)$ be a group, $a \in G$, and $|a|=n$. Then, for all $k \in \Bbb N$, $|a^k| = \frac{n}{\gcd(k,n)}$, we have, $|a^k| = \frac{n}{\gcd(k,mk)} = \frac{n}{k} = m$.
Does it true? On the other hand, in the answer key says that the answer is $\frac{n}{m}$. How to get this?
In your first attempt, note that what you obtained, $(a^k)^m = e$ does not guarantee that $o(a^k) = m$. It tells you that $$o(a^k) \mid m \implies o(a^k) \le m$$
To show that $o(a^k) = m$, we need to also show that $o(a^k) \ge m$. To show this, suppose for a contradiction that $o(a^k) < m$. Then, $\exists t \in \mathbb{Z}^+$ such that $t < m$ and $(a^k)^t = e$. But then, we have $(a^k)^t = a^{kt} = e$ for $kt < km$ (since $t < m$). But this means $o(a) < km = n$, contradiction.
Your second attempt is perfectly valid.