As the old saying goes, "amateurs study tactics, professionals study logistics," and that explains a lot of the problems encountered training police and soldiers in Iraq and Afghanistan. It's not that the Iraqis and Afghans are not brave, or incapable of using their weapons. But in both countries there is a remarkable inability to keep the troops supplied. While Iraq has had modern armed forces for decades, these troops were never supported by an effective supply and maintenance system. There was a shortage of trained people, and an abundance of corrupt officials and people who steal things. The shortages were even greater in Afghanistan, because less than a quarter of the population is literate. So it's much more difficult to recruit people to keep records, or be able to read maintenance manuals.
These logistical problems express themselves in the local economy, where everything is less efficient. It's not just military organizations that suffer. This is a problem all over the world where rule of law, and literacy, are not commonplace. The rule of law is more important that literacy, although the two tend to go together. But many of these nations are, as one diplomat once undiplomatically quipped, "tribes with flags." Tribes or clans take care of their own, and screw everyone else. The West went through that stage, and did not prosper until the corruption was greatly reduced, the populations became largely literate, and most people played by rules.
The terrorists suffer from the same supply problems, but you never hear much about it. The terrorists are operating like the traditional tribal raiders, and spend more of their time (compared to the police and soldiers), just hanging out and getting ready for another burst of activity.
As 19th century European colonial administers learned, and observed, "you can't hustle the East." These men tried to bring modern bureaucracy and industrial organization to less developed parts of the world, and found it was exceedingly difficult. It can, and has been, done. But you can't really hustle the process.