There is a huge amount of largely overlapping but often incompatible medical imaging research software — funded by the US taxpayer (see ie www.nitrc.org or idoimaging.com). I imagine the situation may be similar in other fields, but it is pronounced here because of the glut of NIH funding.
One reason is historical: most of the well-funded, big, software-producing labs/centers have been running for 20 or more years, since long before the advent of git,hg and related sites promoting efficient code review and exchange; so they have established codebases. Another reason is probably territorialism and politics.
As a taxpayer, this situation seems wasteful. As a minion in a small, translational lab without developer resources, it is extremely frustrating as we try to cobble together rickety solutions from a 1/2 dozen or more packages. It's great that the software is being released at all, but the duplication of effort means quality is much lower than it could be given the large number of people involved (easily in the thousands just counting a few developer mailing list subscriptions)
The granting organizations have the power to change this, but obviously they haven't done so. The highest-level PIs who review large grants have a vested interest in maintaining the soft-money fiefdoms, and since the PIs don't actually use the software, they are in the worst position to judge the merits or necessity of software development grants (especially those clever ones couched as research). No one seems to ask: why are we funding x different packages that do 80% of the same thing, but none of them well? These are GUI packages meant for end-users, developed with infrastructure grants."