What lead to ISIS was the US pulling out too soon, leaving a huge power gap that the Iraqi government could not fill. Nation building takes decades. Germany and Japan were not rebuilt overnight to become the US' top allies after WWII: they were fully occupied by Allied forces for at least a generation before control was handed back to their respective local governments.