This behavior, where individuals or a group of birds harass larger predators, is known as mobbing. Unlike many animals, birds can distinguish colors. Birds use colors and patterns to communicate with each other. These may send messages of aggression, attraction, or alarm. Birds can recognize members of their own species by their color patterns, just like uniforms identify sports teams.
Many species attract mates or defend territories with the help of flamboyant advertising plumage.
They wouldn't want to attract attention of predators to their eggs or young birds. Select this text if you would like to learn how feathers get their colors.