This is no accident. The choppers used in Iraq and Afghanistan were designed to be safer, and sturdier, in combat. American helicopters were frequently under fire in the last decade. During the peak period of Iraq combat (2005-2007), helicopters were fired on about a hundred times a month, and about 17 percent of the time the helicopters were hit. But few of the helicopters hit were brought down, much less destroyed.
Contrast this with Vietnam (1966-71). There, 2,076 helicopters were lost to enemy fire (and 2,566 to non-combat losses). In Vietnam, helicopters flew 36 million sorties (over 20 million flight hours). In Vietnam helicopters were about twice as likely to get brought down by enemy fire and casualties were much more frequent. As in Iraq, the main weapons doing this were machine-guns.
Today's helicopters are more robust, partly because of Vietnam experience, and are more likely to stay in the air when hit, and land, rather than crash. The 1960s was also a period of learning how to use helicopters on a large scale, in a combat environment. That experience also went into developing safer ways to fly, and use, helicopters in combat.
For example, in Iraq aircraft losses to ground fire declined every year, since 2003, mainly because of improved defensive tactics. Moreover, the most vulnerable aircraft, helicopters, have been spending more time in the air. The new helicopters are so robust that crew and passengers were more likely to be killed in accidents (weather or pilot error related or because of equipment failure) than because of being fired on. In the last twelve years combat killed 198 passengers and crew, compared to 428 killed by accidents.
In the 1980s, the UH-60 began replacing the Vietnam era UH-1 "Huey" transport helicopter, while the AH-64 replaced the AH-1 helicopter gunship. Not only were these two new designs more effective, they were a lot safer, and expensive. By 2005, the U.S. Army had retired all of its UH-1s. The results of this shift were dramatic. The number of accidents went from over a thousand a year in the early 1990s, to less than 200 a year now. The accidents were more expensive because the AH-64 and UH-60 were more expensive (costing more than three times as much). But a lot of that money went into making the new choppers safer, and more survivable, for their crews when they did get into trouble.