The Prophet ﷺ used to go to Quba both riding and walking.
كان النبي ﷺ يأتي قباء راكبا وماشيا.
Bukhari reported it in the Book of Prayer (1194), and Muslim in the Book of Hajj (1399), both from the hadith of Nafi, from Ibn Umar, who mentioned it.Both of them also reported it from Ibn Numayr, from Ubaydullah, from Nafi, "and he would pray two rakahs there."