There are abelian groups $A$ such that $A\cong A\oplus A \oplus A$ but $A\not\cong A\oplus A$.

Let $E=\operatorname{End}(A)$. The functor $F=\operatorname{Hom}(A,-)$ is an equivalence from the category of finite direct sums of copies of $A$ to the category of finitely generated free $E$-modules.

So $E\oplus E$ is a module with free rank $2$ but is a direct summand of $E\cong E\oplus E\oplus E$, and so has rank $1$.

For an example where the ring has the IBN property:

For any $n>2$ there is an abelian group $A_n$ such that $A_n^n\cong A_n$ but $A_n^k\not\cong A_n$ for $1<k<n$. Let $E_n=\operatorname{End}(A_n)$ and $E=\prod_{n>2}E_n$.

Then $E^2$ has free rank $2$ but rank $1$.