"when we attempt to bring our democracy to these countries, it always fails"
How true.
This was the failing of George W. Bush. He and others in his administration convinced themselves of a sort of messianic policy. They boxed themselves into the idea that the only hope for peace was democracy in the Middle East. They were right, but the task proved beyond the means of mortal man, as I myself at the time and anyone who had read widely about the Middle East could have told them. Sometimes people are too smart for their own good (and the good of those they are charged to protect). It was an honest delusion, but a delusion nonetheless.
Conflict in the Middle East must be managed as best as possible. There's only one Messiah, and it ain't GWB or Donald Trump. The Cold War suppressed problems with one big asterisk, it was a tinderbox that, if it ever exploded, might well have drawn the two superpowers into open military conflict.
In the days of Gulf War 2 I used to argue with friends of mine who supported the Messianic War dream that presupposed Middle Easterners were yearning like their Western counterparts to simply be free to practice democracy. I remember one very, very smart friend sitting across from me at the table trying to persuade me that the Iraqis would rise up and seize freedom once our troops liberated them.
In the '80's I read an enlightening James Clavell novel called "Whirlwind" about a fictional Western oil company operating in Iran with the cooperation of the Shah's government, and the whole country being became engulfed in factional rivalries once the Islamic fundamentalist Khomeini swept into power. There was no possibility of any sort of unity except for that imposed by an all-powerful and ruthless regime. Though a novel, the book introduced me to the social fabric of Iran and the rest of the Middle East. Unless we are prepared to brutally suppress the clan loyalties (and we shouldn't), we can never overcome their overarching, fractious demands.
So we have to decide what actions will keep terrorism at bay, and severely punish it's every appearance. Easier said than done. Ultimately it is a game of whack-a-mole. You can't win, you can only hope to manage it.