A lot of things that don't really make sense on a military level make a lot more sense on a corporate welfare level. Each Virginia-class submarine is built half at Newport News in Virginia and half at Electric Boat in Connecticut; this is far more expensive than just building the subs in one yard, but is intended to keep both submarine manufacturers in business. The Ford class carriers and F-35 warplanes both contain numerous design innovations that don't really work in practice, but could be viewed as experimentation so that we have engineers with experience in various techniques should we ever need to rapidly build up the military later. The F-35 itself has a large number of subcontractors; you could look at that as a way to make sure that expertise in the program remains widely distributed across as many firms as possible.
I suspect the government is content to allow mergers because it doesn't really reduce the deterrent value of having these programs exist, and the whole point of their existence is to funnel money to defense contractors. If we actually got into a major arms race you'd probably see an explosion of new defense contractors as people start chasing the money available, but for now we're at peace with a shrinking military.