But is it really illegal? At least, people who've done it do not rob it, they've payed with money.
The key question is where the goods currently are. Sovereign nations have quite extensive powers in an emergency.
- It is legal for states to seize and redistribute supplies in their own territory. Somebody might owe someone damages and civil penalties for breach of contract when the dust has settled, but that is for afterwards.
- It is legal for states to direct companies and individuals based in their own territory how those companies should deal with their property currently outside the territory of the state. This is subject to the controls of the state where that property currently is.
This action might force companies to break contracts. Again, damages might come due afterwards.
- It is not legal under most jurisdictions for companies to sell goods they do not own (or goods they no longer own). It is legal to comply with government orders to hand them over, see above.
- It is usually legal for companies to enter sales contracts on goods they do not yet own, if that is done in good faith, and mismanagement of the supply might result in delivery contracts being broken. There are civil penalties for that, not criminal ones.
- The state might have entered into an investor protection agreement which specifies arbitration in cases like this. Pulling out of those unilaterally might cut the state off from the global financial markets, or not. That depends on the reaction of the markets.
To put it all into perspective, look at merchant shipping during WWII. Ships ordered to change their course. Ships seized and used for the war industry ...
The premise wrong, because one country is not buying "other country"'s supplies.
What happens here is that supplier S is selling both to country A and country B.
Of course, if in order to fulfill country A's order the supplier ends not having enough stock to match country B's order, then the supplier could be in breach of its contract with B.
In other words, the conflict is between B and S, not between A and B. The reason why S did not provide the goods is not relevant (except if it is a case of force majeure beyond S's control).
Typically this is handled as a civil matter in the appropiate jurisdiction, and not as a criminal one, unless the bad faith of the supplier might amount to fraud or if there are some special laws in place (let's imagine that the supplier works in country B and country B has enacted a law forbidding exports unless country B's order may be met).