The 3rd amendment has two distinct parts:
No Soldier shall, in time of peace be quartered in any house, without the consent of the Owner
This is an absolute prohibition and any law which attempted to coerce the owner would be unconstitutional.
And the second part:
No Soldier shall, ... be quartered in any house ... in time of war, but in a manner to be prescribed by law.
This allows Congress to make laws about when and how a soldier may be quartered in a house in time of war (as defined elsewhere in law).
Now, SCOTUS doesn't decide if a law is constitutional unilaterally (it is, in fact, prohibited from doing so); – it decides disputes between people. "People" meaning legal people which includes corporations and governments as well as natural people.
So if a house owner was required by the government to quarter soldiers, he could refuse and the government would bring a case to force him to do so or, more likely, he could allow it in fact and then go to the court to get an order requiring the soldiers to leave. This would not go to SCOTUS in thewhen a case is first instancebrought as it is an appellate court but towould start in a lower Federal court with jurisdiction. That court would decide if a state of war existed (a matter of fact) and, if not, if the government had the power to make such a law and therefore if the billeting of the soldier was lawful assuming it was done in accordance with that law (a matter of law). It
If it is wartime then the law is enforceable and while the case may contain an obiter dictum that the decision would be otherwise in time of peace, the court would say the soldier could stay. If it were peacetime then the law would be found unconstitutional and the soldier has to go, the obiter dictum in this case saying that it would be lawful in wartime.
When a court finds a law unconstitutinal it means unconstitutional in these (and similar) circumstances; it may be constitutional in other circumstances. This is no different from any other case – same law but different circumstances may give different results. In part, lawyers get paid for arguing either that the circumstances in this case are sufficiantly different that the decision in that case souldn't apply; or vice-versa.