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:
Source: Wikipedia
Sincerely,