For any family of modules, there is a construction analogous to the Cartesian product in $\mathbf{\text{Set}}$ that produces a single module characterized by a universal property.

Direct product of two modules

First suppose ${M}_{1}$ and ${M}_{2}$ are two $R$-modules. Let ${M}_{1}\xc3\x97{M}_{2}$ denote the $R$-module whose elements are pairs $({m}_{1},{m}_{2})$ with ${m}_{1}\xe2\x88\x88{M}_{1}$ and ${m}_{2}\xe2\x88\x88{M}_{2}$, with component-wise addition and scaling. We have two "projection" module morphisms ${\mathrm{\u012a\x80}}_{i}:{M}_{1}\xc3\x97{M}_{2}\xe2\x86\x92{M}_{i}$, which send a pair $({m}_{1},{m}_{2})$ to ${m}_{i}$, for $i=1,2$.

This data satisfies the usual universal property for a product, in that it is universal among all such modules equipped with morphisms to ${M}_{1}$ and ${M}_{2}$. More precisely, for each module $N$ and pair of module morphisms ${f}_{1}:N\xe2\x86\x92{M}_{1}$ and ${f}_{2}:N\xe2\x86\x92{M}_{2}$ there is a unique module morphism $h:N\xe2\x86\x92{M}_{1}\xc3\x97{M}_{2}$ such that the diagram below commutates:

Observe that, as an abelian group, ${M}_{1}\xc3\x97{M}_{2}$ is the usual direct product of abelian groups; similarly, as a set, ${M}_{1}\xc3\x97{M}_{2}$ is the usual Cartesian product of sets.^{[1]}

Direct product of a finite collection of modules

Analogous to the above construction, for any finite collection of $R$-modules ${M}_{1},\xe2\x80\u013b,{M}_{n}$ their direct product is an $R$-module, denoted ${M}_{1}\xc3\x97\xe2\x8b\xaf\xc3\x97{M}_{n}$, together with module morphisms ${\mathrm{\u012a\x80}}_{i}:{M}_{1}\xc3\x97\xe2\x8b\xaf\xc3\x97{M}_{n}\xe2\x86\x92{M}_{i}$, universal among all such data. As an abelian group, it is the usual direct product of the corresponding abelian groups; as a set, it is the usual Cartesian product of the corresponding sets. The additive structure is defined component-wise, as is the action of $R$.

It is common to denote the direct product by $\underset{i=1}{\overset{n}{\xe2\x88\x8f}}{M}_{i}$, in which case the universal property is encoded in the commutative diagram below:

Direct product of an arbitrary family of modules

Finally, suppose $\{{M}_{s}\xe2\x88\u0156s\xe2\x88\x88S\}$ is a family of $R$-modules indexed by some set $S$. Following the pattern we've established, the direct product of this family is an $R$-module, denoted $\underset{s\xe2\x88\x88S}{\xe2\x88\x8f}{M}_{s}$, together with module morphisms $\mathrm{\u012a\x80}}_{t}:\underset{s\xe2\x88\x88S}{\xe2\x88\x8f}{M}_{s}\xe2\x86\x92{M}_{t$ for every $t\xe2\x88\x88S$, universal among all such data. As an abelian group, this is the usual direct product of the corresponding abelian groups; as a set, it is the usual Cartesian product of the corresponding sets.

The difference here between this general case (which includes infinite sets) and the finite case is that the elements of the set $\underset{s\xe2\x88\x88S}{\xe2\x88\x8f}{M}_{s}$ are not really tuples (or sequences) of elements, since the set $S$ might not be linearly ordered. This problem has nothing to do with the fact that the ${M}_{s}$ are modules, but is an issue with sets in general. One solution is to instead construct the set $\underset{s\xe2\x88\x88S}{\xe2\x88\x8f}{M}_{s}$ as the collection of all set maps $f$ from $S$ such that $f(s)\xe2\x88\x88{M}_{s}$ for every $s\xe2\x88\x88S$. Ignoring certain set-theoretic considerations^{[2]}, this does the job. The additive operation and $R$-action are then once again defined "component-wise"; e.g., $(r\xe2\x8b\x85f)(s)=r\xe2\x8b\x85f(s)$, where the right-hand side indicates the action of $R$ on the $R$-module ${M}_{s}$. In other words, for each $s\xe2\x88\x88S$ we can think of $f(s)$ as the value of the $s$-component of the element $f$.

The finite case can be seen as a special case of this general construction by considering the set $S=\{1,2,\xe2\x80\u013b,n\}$ and associating each $n$-tuple $({m}_{1},{m}_{2},\xe2\x80\u013b,{m}_{n})$ with each ${m}_{i}\xe2\x88\x88{M}_{i}$ to a function $f$ on $\{1,2,\xe2\x80\u013b,n\}$ with $f(i)={m}_{i}$ for each $i$.

A word on language

The terms "Cartesian product" (of sets) and "direct product" (of modules, groups, etc.) is a bit antiquated. Each of these types of objects satisfies the "same" universal property from the point of view of category theory, which is simply that of a product. To make matters unnecessarily confusing, categorical products are special cases of a more general notion of limit, which was sometimes called "inverse limit" or "projective limit". This was to distinguish them from the dual of notion of colimit, which was once called "direct limit" or "inductive limit". So a direct product is an example of an inverse limit (not a direct limit), while a direct sum is an example of a colimit (or direct limit). Oof. Let's be kind to ourselves and stick simply with "product" and "coproduct".

More precisely, let ${U}_{1}:R\mathbf{\text{-Mod}}\xe2\x86\x92\mathbf{\text{Ab}}$ and ${U}_{2}:R\mathbf{\text{-Mod}}\xe2\x86\x92\mathbf{\text{Set}}$ denote the usual forgetful functors. Then ${U}_{1}({M}_{1}\xc3\x97{M}_{2})\xe2\x89\x83{U}_{1}({M}_{1})\xc3\x97{U}_{2}({M}_{2})$ and ${U}_{2}({M}_{1}\xc3\x97{M}_{2})\xe2\x89\x83{U}_{2}({M}_{1})\xc3\x97{U}_{2}({M}_{2})$. âŠī¸

For example, you might be wondering what the common codomain is for all such functions? The answer is the fixed universe $\mathcal{U}$, which contains all sets were are allowed to consider. In particular, it should contain the union of the sets of elements of all ${M}_{s}$. âŠī¸