Recall that ISIS rules certain regions of Syria. They collect taxes. They collect utility charges. The Assad regime (who run Syria) let them do that so they can point to a Big Bad: see? Stick with us: the other choice is those guys. ISIS also controls certain oil regions in Syria, and now Iraq. They regulate the price and quality of goods in their territory.
So the Iraqi Army was going up against something like governmental army. That’s not to say that they were invincible: the Kurds have held them off on the border of Turkey for a while. But ISIS isn’t a guerilla army; they are led by some of Saddam’s old generals for instance.