Let $\{M_i\}_{i\in \mathbb{Z}}$ be an index family of $R$-modules. Then we know that the direct sum $ \bigoplus_{i\in \mathbb{Z}}M_i$ is a submodule of a direct product $ \prod_{i\in \mathbb{Z}}M_i$. Let $N$ be an $R$-module and if $$f:\bigoplus_{i\in \mathbb{Z}}M_i\to N$$ is any linear map. Can we always extend $f$ to a linear map $$\tilde{f}:\prod_{i\in \mathbb{Z}}M_i\to N .$$ That is, $\tilde{f}$ is a linear map such that $$\tilde{f}|_{\bigoplus_{i\in \mathbb{Z}}M_i} = f.$$ I know in vector spaces we can always construct $\tilde{f}$ with the help of a basis, but in general modules how do we proceed?
Secondly, if some $f$ has an extention to $\tilde{f}$, is $\tilde{f}$ unique?
No, this is already false for $R = M_i = N = \mathbb{Z}$. Let me change the indexing set to $\mathbb{N}$ to avoid confusion. In this case linear maps
$$f : \bigoplus_{i \in \mathbb{N}} \mathbb{Z} \to \mathbb{Z}$$
can be arbitrary elements of the product $\prod_{i \in \mathbb{N}} \mathbb{Z}$, but it's known that linear maps
$$\tilde{f} : \prod_{i \in \mathbb{N}} \mathbb{Z} \to \mathbb{Z}$$
can conversely be identified with the infinite direct sum $\bigoplus_{i \in \mathbb{N}} \mathbb{Z}$ (this is due to Specker); in other words, a linear map $f$ has an extension $\tilde{f}$ iff it lies in the direct sum as a submodule of the direct product, and the extension is unique if it exists.
If $R$ is a field then extensions exist assuming the axiom of choice and they need not be unique. You can pick them by extending a basis of the direct sum to the direct product, and setting the values of the map arbitrarily on the new vectors in the basis.