A question about invariant factors of finitely generated modules over a PID. A Theorem in our textbook says:
If R is a PID, then every finitely generated torision R-module M is a direct sum of cyclic modules 
$$M= R/(c_1) \bigoplus R/(c_2) \bigoplus \cdots \bigoplus R/(c_t)$$
where $t \geq 1$ and $c_1 | c_2 | \cdots | c_t$.
If we want to classify groups of order 32 and put them in invariant factor form then the abelian groups of order 32 are:
$Z_{32}$
$Z_{16} \bigoplus Z_2$
$Z_8 \bigoplus Z_4$
$Z_8 \bigoplus Z_2 \bigoplus Z_2$
$Z_4 \bigoplus Z_2 \bigoplus Z_2 \bigoplus Z_2$
$Z_2 \bigoplus Z_2 \bigoplus Z_2 \bigoplus Z_2 \bigoplus Z_2$
My question is: The theorem only tells us that "M is a direct sum of cyclic modules". But how do we know what those cyclic modules are? 
 A: The invariant factors are part of the structure of the module itself. You wouldn't be able to say much without looking at the structure of the module directly.
Let's take your 32 elements abelian group as an example.
If one had an abelian group of order 32 prepared, they might go about figuring out which of the listed groups it is by checking orders of elements. Finding an element of order 16, for example, would narrow it down to the top two possibilities.
Why did they generate that list using the factorization of 32? They were simply trying to write down every possible set of invariant factors. Because $(32)$ annihilates $M$, we know that $c_n$ is a divisor of 32 (because $(32)\subseteq ann(M)=(c_n)$.) But $c_{n-1}$ divides $c_n$, so it's going to be in that list of divisors of 32. If $c_{n-1}$ happened to be 4, well then $c_{n-2}$ would need to be a divisor of 4, etc. If you go on this way, remembering keeping the size of the group in mind, you will be able to list all possible lists of invariant numbers, as they did:
$$
32\\
2|16\\
4|8\\
2|4|4\\
2|2|8\\
2|2|2|4\\
2|2|2|2|2\\
$$
In a nutshell, if you can find anything that annihilates $M$, say $(x)$, the invariant factors have to be divisors of $x$.
It's probably going to be easier, though, if you first try to find the primary decomposition of $M$, and then compute the invariant factors from that. (I think that is possible... how was it done again...? Hmm...)
