So there are the two versions of the Fundamental Theorem for Finitely Generated Abelian Groups (FTFGAG). I take the following from A First Course in Abstract Algebra by Fraleigh. The first is as follows:
FTFGAG 1: Every finitely generated abelian group $G$ is isomorphic to a direct product of cyclic groups in the form $$ G \cong \mathbb{Z}_{p_1^{r_1}} \times \cdots \times \mathbb{Z}_{p_n^{r_n}} \times \mathbb{Z} \times \cdots \times \mathbb{Z}$$ where $p_i$ are primes (not necessarily distinct) and $r_i$ are positive integers.
But then we also have the second version:
FTFGAG 2: Every finitely generated abelian group $G$ is isomorphic to a direct product of cyclic groups in the form $$ G \cong \mathbb{Z}_{m_1} \times \cdots \times \mathbb{Z}_{m_r} \times \mathbb{Z} \times \cdots \times \mathbb{Z}$$ where $m_1 | m_2 | \cdots | m_r$.
My question is whether these two hold at all times? So say for $\mathbb{Z}_{20}$, do we have $\mathbb{Z}_{20} \cong \mathbb{Z}_2 \times \mathbb{Z}_2 \times \mathbb{Z}_5 \cong \mathbb{Z}_4 \times \mathbb{Z}_5 \cong \mathbb{Z}_2 \times \mathbb{Z}_{10}$, even though $10$ is not a power of a prime (though of course $2|10$)?
I've also seen statements of the Chinese Remainder Theorem (CRT) which say that $\mathbb{Z}_{nm} \cong \mathbb{Z}_n \times \mathbb{Z}_m$ if and only if $\gcd(n,m)=1$. Does this not contradict $\mathbb{Z}_{20} \cong \mathbb{Z}_2 \times \mathbb{Z}_{10}$ from above? Or is treating $\mathbb{Z}_n$ and $\mathbb{Z}_m$ as rings in the CRT what makes the situation different? I guess what I'm asking in a nutshell is: why don't the primary and invariant forms of the structure theorems for abelian groups (and also modules over PIDs, etc) contradict each other?
Many thanks for any answers.
Edit: So it seems that I didn't see this question which basically answers mine. CRT gives us a way of decomposition but FTFGAG only tells us that some decomposition is always possible. So for FTFGAG 1, $\mathbb{Z}_4 \times \mathbb{Z}_5$ suffices, for FTFGAG 2, $\mathbb{Z}_{20}$ suffices, and for the CRT $\mathbb{Z}_{20} \cong \mathbb{Z}_4 \times \mathbb{Z}_5$ works.