For the case $R$ is a local ring it's a corollary of Nakayama's lemma.
As the notation in the above link, suppose $M$ is a finite generated projective module over $R$, then, first pick a minimal number of generators, i.e., $M=Rm_1+\cdots +Rm_k$, and $k$ is the minimal number with this property, so we get a decomposition
$$R^k=M\oplus N,$$ then, we are left to prove $N=0$.
First, applying $R/I\otimes-$, where $I$ is the unique maximal ideal in $R$, then we get $$(R/I)^k=M/IM\oplus N/IN,$$ and note that $M/IM$, $N/IN$ are vector spaces over the field $R/I$, so by comparing the dimension, we get $N/IN=0$, i.e., $N=IN$, then,
we use the Nakayama's lemma, the Statement 1 in the above link, we get $r\in 1+I$, such that $rN=0$, but $r\not \in I$ and $R$ is local implies $r$ is a unit, so $N=0$.
Remarks. 1) To get the choice of $k$, we can first assume $k=\dim_{R/I}(M/IM)$, then use the Statement 4 in the above link to lift the basis of $M/IM$ to get a minimal set of generators of $M$.
2) A deep theorem of Kaplansky says that any projective modules (not necessarily finitely generated) over a local ring is free.
Over a (commutative) local ring (non necessarily noetherian), any finitely generated flat module is free (Matsumura, Commutative Algebra, Prop. 3.G, p. 21), hence projective.
Best Answer
Let $R$ be a semisimple ring which isn't a division ring, and take an idempotent $e\notin \{0,1\}$. Then we have that $R=eR\oplus(1-e)R$ is a nontrivial decomposition of $R$, and both pieces are cyclic and projective (since they are summands of $R$) hence flat.
Actually neither piece is a free module, but we'll argue here that at least one of them isn't free to simplify things. If they were both free, that would imply that $R\cong R^n$ for some $n>1$ as modules. (Each factor contributes at least one $R$, you see.) But since $R$ has the IBN property, this is impossible.
Thus at least one of the pieces is flat but not free.
If you really want to be concrete, you can use a finite semisimple ring to make things obvious: let's try $R=\Bbb F_2\times\Bbb F_2$. $\Bbb F_2$ is denoting the field of two elements.
The module $I=\Bbb F_2\times \{0\}$ is a direct summand of $R$, but it can't be free: a free module would have to have at least four elements, and this module only has two elements!