I'm sure the various autocratic, dystopian states around the world that would love to see functioning democracies be smouldering piles of rubble are hoping that we think this way...because they certainly aren't thinking that way.
Iraq and Afghanistan weren't about to nuke the US. I don't see the moral justification for work going into those wars, even if there is a possibility that it might not be used solely for invasions, imperialism and bombing weddings.
We are talking about defense in this thread, not offense, but you are in a way proving my point. If Ukraine had nukes would Russia have invaded? Would the US have invaded Iraq if it had nukes?