‚Privateers’ were really commissioned pirates who were commissioned by some nations using letters of marque, that identified them as pirates working in the service of that nation. A letter of marque was a document that granted legal immunity to a pirate as long as he attacked/robbed the vessels of other countries. So a pirate who received a letter of marque from Britain, for example, would be acting in the service of the government of Britain against other countries. This effectively meant that they were mercenaries; pirates commissioned by governments against other states as a form of proxy warfare.
Other nations still regarded them as pirates, and that is why other nations will attack you if you fly the pirate flag at sea.
Some historical background: In 1794 there arrived at Guadeloupe the new French Governor, Victor Hugues, who later issued a decree that allowed pirates to serve as Privateers for the French republic. France was then a revolutionary state, and after the fall of the French king the country was soon at war with England.
Between 1797-98 French privateers captured 336 American and British merchant ships, and in 4 years French privateers captured more than 2,000 British and American ships. Governor Hugues relied on privateers to cripple the British export-import trade in the West Indies, with the hope that it would weaken the British economy so that Britain would not be able to defend itself against France back in the continent.
But France was also allied to the United States at that time, as France had supported the Americans during the American revolution against Britain. The United States, however, continued to trade with Britain in the West Indies because of the huge profits from the sale of sugar and rum. Governor Hugues allowed French privateers to attack both British and American ships operating in the Caribbean in order to bankrupt the British companies there, but the attacks on American ships angered the American government. By 1798 the American government was so incensed with the French privateers that the American government ordered the sinking/capture of all privateers working for France.
That is why being a privateer means that you are allied with only ONE country. The other countries will still regard you as a pirate, and their ships will attack you.
(Photo: British letter of commission signed by Lord Minto, commander of the British East India company forces based in the East Indies, from my personal collection.)