The origin of the structure of large-scale magnetic fields in disc galaxies