Bush successfully assembled a coalition to invade Afghanistan. He didn't even promise that there'd be WMDs there, he just said "They gots terrorists" and a large portion of the UN joined in the invasion.
Upon reflection, the justifications to invade Afghanistan were every bit as flimsy as the justification to invade Iraq.
The head of the organization responsible for the deaths of almost 3000 civilians was known to be present in Afghanistan, and the government refused extradite him.
That seems like a solid casus belli.
Afghanistan was more justifiable. The argument was that it was a failed government that housed a terrorist organization that just attacked US.
What Iraq had to with it, i honestly have no idea. Somehow we pivotted from Afghanistan to Iraq