On the invariance of basis number I know that if $R$ is a commutative ring, then $R^n\simeq R^m$ as $R$-modules is equivalent to $n=m$.---(1)
But there is some confusing example.

Let $A=\prod_{n\in \mathbb{N}}R$. Then $A$ is a commutative ring and $$A^2=\prod_{n\in \mathbb{N}}R\times \prod_{n\in \mathbb{N}}R=\prod_{n\in \mathbb{N}}R=A.$$ Thus $A^2$ and $A$ should be isomorphic as $R$-modules. 
  But it contradicts (1) above. What's wrong?

I also have one more question.

If $M$ is free $R$-module and have a finite basis $S$, is it possible to have another infinite basis?

I know if $R$ is commutative ring with unity, the number of basis should be same. But if it is not, I think it is not true. Is there a counter example?
Thanks in advance for your help.
 A: In your example $A\simeq A^2$ as rings, but not as $A$-modules. (As you already know, this is not possible.)
A free module can't have a finite and an infinite basis. Suppose it has a finite basis $x_1,\dots,x_n$ and an infinite basis $(y_i)_{i\in I}$. Then each $x_j$ is a (finite) linear combination of the $y_i$'s. Let $J\subset I$ be a finite subset which contains all indices of the $y_i$'s which appear in a linear combination as mentioned above. Then they form a system of generators (actually a basis) for our module, so any other $y_j$ is a linear combination of them, a contradiction.
A: an $A$-module is a commutative group $M$ together with a multiplication map $\mu : A \times M \to M$.
In your counter-example, you have got two $A$-modules $(M_1 = A^2, \mu_1)$ and $(M_2 = A,\mu_2)$ and you have argued that they are isomorphic as $R$-modules (there is a group isomorphism between them that is also compatible with the unrelated multiplication maps $\nu_i : R \times M_i \to M_i$).
But this isomorphism (that you didn't completely describe) is not compatible with the maps $\mu_i$.
For example, the image of $\mu_1(1,0,0,\ldots)$ is an $R$-module of rank $2$, while the image of $\mu_2(1,0,0,\ldots)$ is an $R$-module of rank $1$.
