Flamingos are known for their one-legged perch, but researchers think they've finally figured out how and why they do it