1) America has Europe by the balls because we provide most of the major military security guarantees.
2) Iraq wasn’t exactly a peaceful nation (see: Kuwait)
3) Both Iraq and Afghanistan were governed by non democratic governments; a dictator in one and by religious zealots in the other
4) No one other than the local middle eastern Arabic countries were threatened by this action by the USA, and they didn’t have enough power to put pressure on the USA
In Ukraine, Russia invaded a neighbor of NATO countries, Ukraine was actually a peaceful nation and has a democratically elected government, and the countries that don’t like Russia actually have the power to try to stop it and can get by without anything from Russia.
Afghanistan was harboring al Qaeda and Iraq was threatening use of WMDs. They weren't peaceful nations.
The latter turned out to be bluster, supported by terrible intelligence and a U.S. administration that didn't have the wherewithal to counteract its own confirmation biases, and that deserves its own appropriate condemnation, but it's nowhere near the same thing.
America invaded Iraq and Afghanistan on flimsy pretexts and then continued to occupy the latter for what, 20 years?
Why wasn’t there similar international pushback against that?