Since we are delving into pure theory here, and not trying to cite real world examples...
Country A has a recent shortage of resource A and has stopped exporting it to country B. No other country has surplus to offer country B, and country B cannot continue functioning without it. The only way for them to avoid a massive humanitarian crisis in their country is to invade country A.
A is not in the wrong, they need the resource as well and cannot share it. I would argue B would not be in the wrong for invading A, since they need to in order to serve their people. This is a simplistic case of both countries needing the same resource.
If you don;t like that scanario, we could make it even more neutral. A and B are both running low on a resource, and the only new source is island C. Both want to claim island C, cannot continue without it, and island C does not have enough of the resource to share, so both sides are willing to fight for it, as doing so is their only avenue for serving their people.
If we take a global view of what is best for humanity as a whole, A and B should share in these scenarios. It will hurt both of them a great deal to do so, and cause a massive humanitarian crisis in both countries, and be the end of the governments.
If we take a nationalistic view though, both A and B are best served by war. Their people WILL suffer if they don;t Their people MIGHT suffer if they do, as whoever wins the war gets to avert the crisis in their country.