In the event of such an occurrence, the country banning its citizens from travelling to country B is in essence making a (hopefully temporary) law. This affects the citizens of this country only (unless it's a decree across say, a host of countries ruled by one government).
These laws are local only and cannot impact on another country. No other country ever has to listen to these laws, as they belong to country A. Heck, Country B might like some tourists, as that tends to bring money in.
Indeed, if Country A is about to go to war with Country B, one might consider it even less likely that Country B will help out with enforcing their laws.
As a commenter said, one example is the US stopping its citizens going to Cuba - but if you as a US Citizen find a way into Cuba, say, via Canada - neither Canada or Cuba is going to stop you travelling there.
On the other hand, if Country B bans citizens from country A coming to it, well then you're just going to get turned away at the border, and airlines will check your visa and likely not fly you there.