The story
Nautical origin. The word colors (or colours) refers to the flag or ensign which every ship is obliged to fly at sea. It was once a common deception of pirates to “sail under false colours” and fly a friendly flag in order to get within close range of potential targets (other ships) without exciting suspicion. Only when the pirate ship reached close quarters would it unfurl its true colours.
Etymology from Wiktionary, CC BY-SA 4.0.