Sometimes a foreign force will overthrow your elected government, because they want your oil, appoint a dictator instead and provide him with support in exchange for military interest. After decades, he is ousted, foreign relations are understandably sour and your neighbor decides to invade, so the powers provide support lest he be defeated and you are pronounced a country non-grata.
More to the point, it shouldn't be the or a country that appoints leaders. They should be appointed by the people, but for various reasons it has a rather poor success rate.