How does the Government win that case when those denied visas and those whose visas were canceled on the basis of their religion go to court in the US?
"...canceled on the basis of their religion..."
Some other basis for denial or cancellation must be used.
First of all, aliens residing in alien lands are not subject to judicial process in Article III courts, nor is the question of granting or denying them visas subject to the jurisdiction of said courts.
Secondly, it has repeatedly been the case that the exigencies of war permit all sorts of executive action which would normally be considered impermissible.
As President Lincoln so famously put it, "the Constitution is not a suicide pact".