The Prophet ﷺ used to go to the Mosque of Quba (sometimes) walking and sometimes riding.
Added Nafiʿ (in another narration), "He then would offer two rakʿat (in the Mosque of Quba)."
كَانَ النَّبِيُّ ﷺ يَأْتِي قُبَاءً رَاكِبًا وَمَاشِيًا
زَادَ ابْنُ نُمَيْرٍ حَدَّثَنَا عُبَيْدُ اللَّهِ عَنْ نَافِعٍ فَيُصَلِّي فِيهِ رَكْعَتَيْنِ