Do both versions (invariant and primary) of the Fundamental Theorem for Finitely Generated Abelian Groups hold at the same time? 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.
 A: You are correct about the Chinese remainder theorem indeed $\mathbb{Z}_{20} \not\cong \mathbb{Z}_2 \times \mathbb{Z}_{10}$. The problem with applying the 2nd version in this manner is the rank uniquely determines the group. So for example $\mathbb{Z}_{20}$ is rank 1, that is it already is written in that form (trivially) 
A: For your example, $\mathbb{Z}_{20}$, 


*

*The first decomposition gives you $\mathbb{Z}_{20}\simeq\mathbb{Z}_{2^2}\times\mathbb{Z}_5$.

*The second decomposition gives you $\mathbb{Z}_{20}\simeq\mathbb{Z}_{20}$.  In other words, this one doesn't break up the abelian group at all.

*You can note that $\mathbb{Z}_{20}\not\simeq\mathbb{Z}_2\times\mathbb{Z}_{10}$ since $\mathbb{Z}_{20}$ has an element of order $20$ while the maximum order of an element of $\mathbb{Z}_2\times\mathbb{Z}_{10}$ is $10$.
The idea of the statements is that it is possible to write it in this form, not that all products of the given form are isomorphic to the given group.
A more interesting example might be given by 
$$
\mathbb{Z}_4\times\mathbb{Z}_6\times\mathbb{Z}_5.
$$


*

*The first decomposition gives you
$$
\mathbb{Z}_4\times\mathbb{Z}_6\times\mathbb{Z}_5\simeq \left(\mathbb{Z}_{2^2}\right)\times\left(\mathbb{Z}_2\times\mathbb{Z}_3\right)\times\mathbb{Z}_5\simeq \mathbb{Z}_2\times\mathbb{Z}_{2^2}\times\mathbb{Z}_3\times\mathbb{Z}_5.
$$

*On the other hand, the second decomposition gives you 
$$
\mathbb{Z}_4\times\mathbb{Z}_6\times\mathbb{Z}_5\simeq\mathbb{Z}_2\times\mathbb{Z}_{2^2\cdot 3\cdot 5}=\mathbb{Z}_2\times\mathbb{Z}_{60}.
$$
The group on the right combines the highest powers of each prime that appear in the fully expanded product of the first decomposition, then you work your way down by induction.
