Because the eat blue-green algae.
These are rich in cartinoides which are responsible for the color of the feathers.
Bonus fact:
Why do flamingos stand on one leg?
It's complicated. There are two theories at the moment:
- it is energy efficient for them to do so. Recent studies have shown that they can stand on one leg with no muscle activity.
- they sleep with only one hemisphere at sleep at a time - like dolphins.
Source: Wikipedia
Sincerely,