Why is every vector space free, but not every module?

For every vector space $$V$$ over a field $$K$$ we have that $$V \cong K^n$$ for some natural number $$n$$, and so every vector space has a basis (of $$n$$ elements in this case). Therefore every vector space is free.

However, for modules, this is not the case. Most modules are not free. Let $$R$$ be a ring, and $$M$$ and $$R$$-module, then we don't necessarily have $$M \cong R^n$$ for some $$n$$, not even $$M \cong R^{(I)}$$ for some set $$I$$.

Why is this the case, conceptually? The only different is that we are working over a ring instead of a field. To me, the vector space case seems weird, since it is normally not the case that every algebra in some class is free. For example we also don't have that every group is a free group, etc.

• Every vector space has a basis is equivalent to the axiom of choice. Btw, I think your $n$ is not necessarily a nature number, perhaps written $K^B$ is better. Commented May 2, 2023 at 22:22

More precisely, if you have a closer look to the proof of the fact than any $$K$$-vector space has a basis, you will see it relies heavily on the fact that any non zero element is invertible.
For example, you often have to use the fact that if vectors $$x_1,\ldots,x_n$$ are linearly dependent, then some $$x_i$$ is a linear combination of the others.
This is not true for arbitrary base rings. For example, in $$\mathbb{Z}$$, $$2$$ and $$3$$ are dependent since $$2 \cdot 3 - 3 \cdot 2=0$$, but $$2$$ is not an integral multiple of $$3$$, and $$3$$ is not an integral multiple of $$2$$.
Another example is that $$R[T]$$ is a pid iff $$R$$ is a field.