The NATO treaty applies to attacks on a country within the Treaty Area. The key here is Article V:
The Parties agree that an armed attack against one or more of them in Europe or North America shall be considered an attack against them all and consequently they agree that, if such an armed attack occurs, each of them, in exercise of the right of individual or collective self-defence recognised by Article 51 of the Charter of the United Nations, will assist the Party or Parties so attacked by taking forthwith, individually and in concert with the other Parties, such action as it deems necessary, including the use of armed force, to restore and maintain the security of the North Atlantic area.
It has the term "such action as it deems necessary," which is not an automatic mechanism. It also says "Europe or North America."
- The Syria conflict spilled into Turkey. This did not trigger the NATO case since NATO did not see a serious threat against Turkish territory.
- The UK fought Argentina to defend the Falklands. Not a treaty case, because the Falklands are South Atlantic islands. Also not exactly a defensive treaty with the Falklands, but it should answer your question.
- The US and several allies went to war against Iraq to defend Kuwait. Again not a NATO case. Some NATO members helped, in a coalition of the willing rather than the NATO framework.
So NATO members can clearly go to war without the rest. It remains an interesting question how NATO would act if a NATO member goes to war and gets counterattacked on their territory for that reason.