Be they a pirate galleon or friendly ship, over the years all water vessels have flown a flag from their mast so they could be recognised from a distance.
Friendly ships would normally fly their home country’s flag so other sailors knew where they were from.
Less friendly sailors (pirates), however, in order to confuse or make an attack easier, would also fly these flags (the ones from friendly countries) in the hope that the crew on other ships would mistake them as nice people.
In fact, most pirate ships would carry with them all kinds of flags from all kinds of places. That way they could hoist the one of the nation most liked by the people they were trying to con or rob. Hoisting these flags was known as flying ‘false colours.’
At other times, though, when chasing a ship they wanted to catch and were hoping to terrify its crew in to stopping (basically, when the pirate ship wanted to scare sailors rather than appear friendly) they would fly a plain white flag.
However, if the ship refused to stop, they would take down their white flag and run up the red one. This was to send a message that said, ‘We’re going to catch you, and when we do we’ll board your ship and get you all.’