When the researchers exposed the plants to a longer light cycle, they found that it disoriented their swaying pattern as if they were experiencing a jet-lag.
So like animals that have an internal 24-hour clock that responds to light and regulates when to sleep and eat (and other physiological process,) researchers believe that that sunflowers also have this biological circadian rhythm that helps regulate their growth, which causes those swaying movements.
During the day, one side of the sunflower stem elongates, causing its head to tilt east, and at night time, the other side of the stem stretches, causing its head to tilt west.
As with any organism behavior, their movement is likely an adaptive trait.
Researchers found that ones with disrupted tracking so that they faced the west/wrong direction when the sun rose, saw a decrease in growth and attracted less pollinators.