Thawban reported,

The Messenger of Allah ﷺ was brought a riding animal while he was accompanying a funeral procession, but he refused to ride it. When he departed, a riding animal was brought to him and he mounted it. He was asked about this, and he said, "The angels were walking, so I would not ride while they were on foot. When they left, I rode."

Azami 3682

Sahih

عن ثوبان

أن رسول الله ﷺ أتي بدابة وهو مع الجنازة فأبى أن يركبها، فلما انصرف أتي بدابة فركب، فقيل له: فقال: إن الملائكة كانت تمشي فلم أكن لأركب وهم يمشون، فلما ذهبوا ركبت.

الأعظمي 3682صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Deceased, carrying the funeral bier, and standing for it
Section
Riding upon departing
Numbering
Jami al-Kamil 3682 (2nd edition)
Azami 3682