I believe that typically, restricting ticket purchases to residents of the country in question is done in order to segment the market. In economics, charging different fares in different markets depending on market characteristics (such as income per capita etc.) is called price discrimination and is supposed to maximize profit.
In the case of KLM, I imagine the NW connection may have something to do with it. They seem to split the market with e.g. KLM predominantly selling to customers ex. Europe while NWA does the same ex. USA.