Genes and instincts don't think. They do not have motivations. They cannot be selfish (or altruistic, for that matter). The ‘selfish gene’ is a ~metaphor~.
It helps to understand how evolution works to think of genes as selfish. It helps to understand how people work to remember that our instincts evolved. But that doesn't make all human behaviour inherently selfish any more than it makes all human language inherently written in only 4 letters (which is also a metaphor when applied to genes, by the way).
Whether our instincts are actually making cost-benefit calculations in our subconscious is an interesting question, but without any contrary evidence from psychology, I expect that they're based on much simpler rules of thumb. And sometimes these rules of thumb, although they developed competitively through evolution, urge a person to be cooperative —sometimes even when anybody (consciously or subconsciously) could see that it's not in the person's interest.
Knowing how evolution works, we can be sure that such an instinct (at least if it's widely spread) would have been helpful (either to the person with the instinct or to this person's close kin) most of the time —in the hunter-gatherer societies in which we evolved. In a modern industrial society, where kinship groups are more spread out and we often come into close long-term contact with people whom we're not related to, such an instinct could more easily cause cooperation that benefits people who are not close kin.
I expect that this actually has a lot to do with how communism manages to work not only in families but also in small communities of unrelated people with some other common bond (but not so well in larger communities —nothing above 150, to judge from Pandarsenic's link). But I don't have any clear evidence for that; it would be interesting to see if any psychologists have ever studied this (to see if communards act towards fellow communards the way most people act towards, say, cousins).