The Messenger of Allah ﷺ used to go to Quba both riding and on foot.
أخبرنا قتيبة عن مالك عن عبد الله بن دينار
كان رسول الله ﷺ يأتي قباء راكبا وماشيا
Reported by Muslim in the Hajj chapter, section on the merit of Masjid Quba etc., hadith 519/1399, from Qutayba, and by Bukhari in the chapter on the merit of prayer in the masjid of Makkah and Madinah, section on whoever comes to Masjid Quba every Saturday, hadith 1193, through the hadith of Ibn Dinar, transmitted by him. It is also found in Muwatta, the narration of Abu Musab, 217/1, hadith 553, and in Kubra, hadith 777.