Alliances are different from collective security systems. Collective security is designed to be inclusive. Any country can join, and any country, even a member, can become an enemy that must then be disciplined by the other members. As noted, the United Nations was designed as a collective security system. After the Cold War ended and Iraq invaded Kuwait, the United Nations authorized military action against Iraq even though it was a UN member.
Alliances are very different.
Unlike collective security systems, they are exclusive, because they have a particular enemy in mind. For NATO, that threat was the Soviet Union. That, of course, is the nub of the argument. Despite all the rhetoric about the end of the Cold War, a new NATO, and so forth, the fundamental purpose of NATO is to provide an American security guarantee to countries that are afraid of Russia. To be sure, those fears are not baseless.