The best outcome is for nobody to buy weapons; But if A buys weapons and B doesn't, A gets all if B's stuff; So the consequence of being the only nation not to buy weapons is disaster.
If there is no C and if A and B mutually decide to not buy weapons are they better off?
Yes.
Hence the value of organisations like the USA or the EU, in which states don't need to arm themselves against each other.
Except that this doesn't work in a globalised world, unless at least a large majority of states sign up to a single unified non-aggression pact, and them perhaps pool resources to defend the pact nations against the few rogues.
The UN is supposed to work like that; But it never has, because Russia, China, and the US don't trust each other at all, and they have veto powers that prevent the rest of the UN from having any say in matters where one of the five permanent security council members disagrees with the global consensus.
It all probably sounded like a much better idea back in the 1940s, when they were still thinking of each other as the Allies who had won the war.