R. S. McNamara was the kind of "Intellectual" who can do wonderful things in an academic setting but is incapable of tying his own shoes. He did do some intelligent things, but he did them without understanding how it effected the military systems overall.
One of the things he found when he became the Sec. Def. was that each service had different everything. Shoes, fatigues, planes, band instruments, all kinds of stuff. So he implemented a policy to streamline supply. The services had to have the same basic equipment and use the same vendors. Instead of half a dozen different footwear contracts all the services had to buy and issue the same boots, fine so far.
However, when it came to fighter planes, the Navy, Air Force and Marines all had different requirements. The Navy needed twin-engined fighters that could operate off of carriers and they needed to outclass enemy land-based fighters (better avionics, more power, etc.) and can do multiple jobs because a carrier only has so much space. The Air Force OTOH, uses air-bases so space is not as big a concern, the Air Force wanted cheaper dedicated units (Fighter, ground attack, bombers, interceptors, etc) so they could put more planes in the air. The Marines needed a dedicated ground attack/close support aircraft which had the ability to defend itself because the Marines aircraft are for supporting the ground troops not chasing the other guys around and establishing air superiority. 3 different missions, but McNamara wanted 1 plane, so everybody got the F-4, which was a good aircraft but it was a 'one-size-fits-all' design that didn't anything particularly well. It was a decent fighter, until it ran out of missiles as it had no gun. It did ground attack pretty well, but not as well as a plane designed for it, and it was too fast for really good close support (although many pilots did a yeomans work with it none the less).
McNamara didn't understand the problem and frankly, didn't care. He decided that the US could by thousands of F-4's, make everybody use them and save a fortune but reducing the cost of spare parts and training. he priced the trees and decided that the forest didn't matter.
the M-16 debacle was more of the same plus. The Air Force had a requirement for a new rifle as far back as 1956 (IIRC) for a rifle that had particular characteristics;
1) Effective range of 300meters
2) Flat shooting
3) More accurate than current service weapons
4) Size and weight comparable to the M-1 Carbine
5) Minimal penetration of hard targets
Number 5 was the kicker! The Air Force had learned the lesson from WWII that if the baddies get in amongst your aircraft and equipment your troops can do as much or more trying to defend them damage than the enemy will do trying to destroy them. The Air Force wanted something that would MINIMIZE the damage if rounds struck the aircraft or missiles or radar systems or whatever. The AR-15 and it's .223 Remington ammunition was just the thing for this as the bullets would tend to break up hitting the skin of the planes and the fragments were unlikely to do much damage to the internals. The fact that the AR-15 was known to be less robust than the M-1 or other battle rifles, or that the killing power of the weapon was reduced did not matter much since, at an airbase, armorers, spare parts and bunkers full of ammo are readily available.
McNamara saw the AR-15 at a firepower demonstration at an Air Force base (Lackland?) and thought it was neat. He was a big fan of high-technology and thought that the aluminum and plastic weapon was just that. At the same time the M-14 was having huge problems, it was more expensive than had been estimated, and was proving to be less useful than previously believed (remember it was supposed to replace the M-1, the M-3 submachinegun and the BAR). McNamara had Cyrus Vance (then Sec. Army) do further testing on the AR-15 and instead of telling him it was not what the Army and Marines needed, and exactly why, the brass simply fudged the tests and did everything in their power to fail the weapon, just as they had done in the late '50's. McNamara was tired of the services bucking him and thought that the fight over the AR was just more of the same. In 1963 he shut down Springfield armory and ordered the services to adopt the AR as is.