“I heard the Messenger of Allah ﷺ say: ‘The rider should travel behind the funeral (procession) but the one who is walking may walk wherever he wants.”
سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ الرَّاكِبُ خَلْفَ الْجِنَازَةِ وَالْمَاشِي مِنْهَا حَيْثُ شَاءَ