After WWII and decolonisation, a new breed of educated, progressive and secular leaders arose across former colonial states. In the Middle East, this was characterised by the influence of Egypt's Nasser. These leaders weren't afraid to stand up to religious fundamentalism. Here is a 1966 video of Nasser making fun of the Muslim Brotherhood trying to force women to wear the hijab[0]. There were secular governments across the Middle East, including Iran, Iraq, Syria, and Lebanon.
However, these secular and socialist leaders were seen as too close to the Soviets by the US, despite many of them explicitly participating in the Non-Aligned movement, and America and its allies quickly acted to counter their influence and depose them when possible.
The major political opponent to anti-imperialist socialism across the Islamic world were the religious fundamentalists, so they were the ones who were backed by the West.
Western support for Saudi's and their Wahhabist ideology is well known. Indonesia's Sukarno was deposed in an American supported purge backed by Islamic fundamentalists, described by the CIA itself as "one of the worst mass murders of the 20th century". Hamas was propped up in Palestine by the Israelis as a counter to Arafat's secular Fatah[1]. Western efforts to undermine Nasser and fund his political opponents(surprise... Islamic fundamentalists) are well documented. The crushing of Nasserism in the Arab world with the help of the Saudis and Israelis is regarded as one of the great triumphs of post WW2 American foreign policy. The groups that formed Al Qaeda and the Taliban were supported by Americans as counters to the Soviets in Afghanistan. There is also consistent American support for the Pakistani government, even in the face of genocide of millions[2], in an attempt to counter the spooky "socialist" and secular India.
And all that is discounting the reactionary sort of fundamentalism that might arise as a result of constant war and interventionism by the West in the Middle East.
It makes me sad when I see "westerners" criticizing Islamic extremism without recognizing their own culpability in the current state of affairs. It is short-sighted and illogical to divorce the political and social situation in the Islamic world from centuries of western foreign policy.
[0]: https://www.youtube.com/watch?v=0fswb4a9jcU [1]: https://www.wsj.com/articles/SB123275572295011847 [2]: https://en.wikipedia.org/wiki/1971_Bangladesh_genocide