I tried to search for a similar problem on the site, but none appear.
Definition 1 : Let $A$ be a commuting ring with identity. If $M = \sum_{i \in I } Ax_i$ then $x_i$ are said to be a set of generators of $M$. An $A$-Module is said to be finitely generated if it has a finite set of generators.
Definition 2 : A free $A$-module is one which is isomoprhic to an $A$-module of the form $\bigoplus_{i \in I } M_i$ where each $M_i \cong A$.
Statement : A finitely generated free $A$-module is therefore isomorphic to $A \oplus \cdots \oplus A$ for some $n > 0 $.
What I attempted: I tried constructing an explicit isomorphism. By Def 1. There exists a minimal finite set $\{x_1, \ldots, x_k \} \subseteq M$ such that it generates $M = \bigoplus_{i \in I } A_i$. Hence, consider $$ \phi: A^k \rightarrow M, \quad (a_1, a_2, \ldots a_k ) \mapsto a_1x_1 + \cdots a_kx_k $$ $\phi$ is a homomorphism, and is surjective by definition 1. Suppose exists non zero $(b_1, \cdots, b_k) \in A^k$ such that $b_1 x_1 + \cdots b_k x_k = 0_M$...
but unlike vector space we cannot replace $x_1$ to contradict minimality...
Suppose $M=\bigoplus _{j\in I} A$ is finitely generated by $\{x_i\mid i=1\ldots n\}\subseteq M$. We always keep in mind that the definition of the direct sum means that each element is uniquely expressed as a finite sum of elements from different coordinates.
Consider one of the $x_i$: when expressed as a tuple in $M$, it is nonzero only on finitely many indices in $I$, as are all its $A$-multiples.
It is possible, then, to take the union each of these finite sets over all the generators, and still have a finite set $F$. Clearly if you take a linear combination of the generators, the indices on which the combination is nonzero is contained in $F$. But that means the span of the generators (all of $M$) is contained there, so that $M\subseteq \bigoplus _{j\in F}A$.
This shows why it is not possible for $I$ to be infinite.