The US is in ideological wars with China (CCP) and Islam. Those may not be wars the US chose, but it is what it is, because there is no common ground in disparate ideologies.
The Kingdom of Saudi Arabia (KSA) relies on the US to buy oil and act as military mercenaries when threatened by local countries.
In the short term, KSA is an ally of the US, but in the long term, there are too many ideological and religious differences.
So at some level, KSA did cause 9/11, although likely in a circuitous way (some funding here, some operational support there, etc.) It's unlikely there was formal military support in any way, because that's counter-productive to the ruling family's goals, but KSA has strong internal security and they know what's happening.
Iraq is a different story, or rather, their leader, Hussein. He invaded Kuwait, threatened to invade KSA, etc.
The US govt. was paid to defend KSA. Bush 2 felt he owed Bush 1 the removal of Hussein. And German and French ambassadors massaging arms sales told Hussein he was untouchable by the US. The US sent an envoy to negotiate a peaceful standdown, but was perceived as belligerent. So war it was.
The "fig leaves" for invading Iraq were that a man who wanted to become the Iraqi President said bad things about Hussein, and that "aluminum tubes" were found in Iraq, supposedly useful in building a nuclear bomb. So the Whitehouse pretended those were adequate justifications, and that Hussein was tied to 9/11, despite knowing immediately that most of the participants were on Saudi passports.
Ironically, Hussein was the only leader capable of uniting Iraq, despite being from a minority ethnic group. Even better, he was a US ally long before the Iraq war.
Hussein's desire to become "the modern-day Suleiman" and rule all of the Middle East led to a large part of its destruction.
But the US could have been more on top of the situation there - maintaining better relations with Hussein, having better intelligence, training and equipping the Kuwaiti armed forces better, etc.
So there's a long backstory to the invasion of Iraq, and the US had reasons, but it wasn't what was told to the American people (I remember the absurd sound bites on TV at the time. I was like, "I can buy aluminum tubes down the street.")