NATO was originally organized to counter the threat of Soviet (e.g. Communist) expansion in Europe. That was its primary purpose from when it was created in 1949 until the end of the Soviet Union in 1991.
Ever since that time, NATO's mission has shifted to peacekeeping and security in the Atlantic Zone (e.g. Western Europe and East Coast of Canada and U.S.), and its primary adversary has been extremist terrorist groups such as Al-Qaeda and ISIS.