If a capitalist country is attacked it will retaliate and defend itself using the most powerful kind of army possible: a volunteer army of individuals who do not wish to live their lives as slaves.
A capitalist country does not trade with the governments of countries that enslave their citizens.
Any collectivist state (such as North Korea in the 21st century) that disregards individual rights is an outlaw and has no right to exist, and to trade with such a country is to sanction and support them.
Regarding nation-states, the principle is best expressed by Thomas Jefferson when he says: “Peace, commerce, and honest friendship with all nations-entangling alliances with none.”
And in a similar vein with George Washington:
The great rule of conduct for us, in regard to foreign nations, is in extending our commercial relations, to have with them as little political connection as possible. Europe has a set of primary interests, which to us have none, or a very remote relation. Hence she must be engaged in frequent controversies the causes of which are essentially foreign to our concerns. Hence, therefore, it must be unwise in us to implicate ourselves, by artificial ties, in the ordinary vicissitudes of her politics, or the ordinary combinations and collisions of her friendships or enmities … it is our true policy to steer clear of permanent alliances with any portion of the foreign world; so far, I mean, as we are now at liberty to do it; for let me not be understood as capable of patronizing infidelity to existing engagements.— George Washington’s Farewell Address