Part of the problem is the United State's for leaving Iraq the way it was and the other half is letting the corrupt and incompetency go for so long in the Iraqi leadership. Like seriously, you could have a guy who was trained by the US army to lead a regiment, instead you get the spineless dunce nephew get a powerful position in the Iraqi army because his rich daddy bought his position.
Iraq has received weapons from both the US and Russian Federation as well as having their army trained by the US. Instead, they just ran away kicked back and watch Fallujah get overrun by fighters. Pretty much the only ones putting up a fight are a the Kurds and a few groups of the Iraqi Army which has received arms from Iran as well.