These wars in the Middle East are like a lesson in ecology.  When the U.S. kills off the top predator in a country, the smaller predators move in.  In North America, when the wolves were killed off in the most of the Eastern part of the continent, the coyotes moved in.   When the U.S. killed off the dictators in the those Middle East countries, first al-Qaeda, then Islamic State moved in.  In Afghanistan, the U.S. has been so "successful" at fighting the Taliban, that the Islamic State found room to move into that country.
Mother Nature hates a vacuum, or as Aristotle put it: “Nature abhors a vacuum.”