We did provide logistics and training to the Iraq military, and either sold or gave them billions of dollars in weapons. And for all that they folded like a cheap suit because al-Maliki chose his military leaders based on loyalty and not ability. How was the U.S. supposed to prevent that?
With a _Resident not sympathetic to muslim terrorists, really pretty simple.