Torsion module decomposition into cyclic factors.

I am trying to resolve some confusion about the decomposition of a torsion module into cyclic factors.

Let $R$ be a PID. Let $M$ be a finitely generated torsion $R$-module. That is, $M=T(M)=\{m \in M\mid rm=0 \text{ for some } r\in R\}$. The fundamental theorem of finitely generated modules over a PID then gives a decomposition of $M$ into cyclic factors: $M\cong Ra_1 \oplus \cdots \oplus Ra_n$.

On the other hand, given any set $A$, we can construct the free module $F(A)$ on the set $A$, (as on the bottom of page 354 of Dummit & Foote). What happens if we take the set $A=\{a_1,...,a_n\}$ and construct the free module $F(A)=Ra_1 \oplus \cdots \oplus Ra_n$? This module looks to be the same module as above, but that's impossible, since one is free and the other is torsion. Thus, the action defining $F(A)$ as an $R$-module must be different from the action defining $M$ as an $R$-module, right?

As you said, $F$ is the free module on the set $A$, that is, the elements $a_i$ form a basis of $F$. Now recall the following: in general, $Ra\simeq R/\operatorname{ann}(a)$, where $\operatorname{ann}(a)=\{r\in R:ra=0\}$. The difference between your two examples is that $\operatorname{ann}(a)=0$ when $a$ is linearly independent over $R$, while $\operatorname{ann}(a)\ne0$ whenever $a$ is a torsion element.