It's a statistical guess, as with most phenomena. When individuals, alone, consistently travel toward direction without observable prompting, it's expected there is another stimuli. This may be an unseen force (birds following magnetic fields). However, it appears there is a genetic component.
https://archive.is/vt6rU#selection-797.2-797.236
Notably: "They also inherit from their parents the directions in which they need to fly in the autumn and spring, and if the parents each have different genetically encoded directions, their offspring will end up with an intermediate direction."