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?