The origin of the 28- to 29-day recurrent patterns of the solar magnetic field