It's not exactly that simple: Islamists (and religion in general) is also perceived to be an antidote to Marxism. At the height of the Cold War and bordering Soviet Union, the west resorted to creating and supporting religious groups "Mujahedin" in Afghanistan (Taliban v0.1) and Khomeini in Iran.
The Late Shah of Iran is on record constantly warning about "Red regression" (referring to Communists) and "Black regression" (referring to Islamic fundamentalists) as threats of the nation and the 1979 revolution succeeded by them joining forces (and the commies got the axe afterwards). Funny that in the western world, we are seeing the extreme left/woke anti-Americans and the Islamists join forces again too, despite being cut of very different clothes: the general American left narrative is silent on issues of Islam (particularly bad when it comes to women and LGBT) as it contradicts their own narrative of fighting "Islamophobia". I doubt this ends well.