Let us start with the persons who are who are authorised to perform funeral rites of a deceased person.
Persons authorized to perform last rites:
1. O Lord, now tell me who are authorised to perform obsequies and what are the methods of performance prescribed in the shästras.
The lord said:
2. Son, grandson, great grand-son, his brother and brother’s progeny, so also sapiṇḍa-progeny— all these are authorized to perform the obsequies. In their absence, samānodaka.progeny of all these can perform the rite.
3-4. If both the families are maleless, the women should perform the obsequies. Or the king may perform all the rites— the preliminary, the middling and the final. O bird, the Ekoddishta shrãddha should be performed every year.
Chapter 8, Preta Kaanda, Garuda Purana
So, a son can perform the rites, preliminary, middle and final.
Is there any mention of varna of the son?
Not directly in the Garuda Purana. But the word used is Putra.
Manu Smriti gives who is our descendant and who can be a legal heir. A boy born of legal or authorised relationship can be heir of the property and that son belongs to you.
Manu Smriti or other smritis do not say inter caste marriages are punishable offense. A Brahmin is allowed to have multiple wives belonging to different castes. There is a hierarchy among them and the sons begot.
A Brahmana can marry a Kshatriya or Vaishya girl; a Kshatriya can take a Vaishya wife, and a Vaishya can wed a Sudra's daughter. But the member of an inferior caste can not wed a girl of superior caste.
Vyasa Smriti,Chapter 2,verse 11.
Manu says the following: (Translated by Ganganath Jha)
haret tatra niyuktāyāṃ jātaḥ putro yathaurasaḥ |
kṣetrikasya tu tad bījaṃ dharmataḥ prasavaśca saḥ || 9.145 ||
The son born of the ‘authorised’ woman shall inherit, like the ‘legitimate’ son; as legally that seed is of the owner of the soil and the offspring belongs to him. [Manu Smriti 9.145]
So, a son born of 'authorised' woman (legal wife) and born in a prescribed manner even though born of other caste is entitled to property and will be legitimate son.
tryaṃśaṃ dāyād hared vipro dvāvaṃśau kṣatriyāsutaḥ |
vaiśyājaḥ sārdhamevāṃśamaṃśaṃ śūdrāsuto haret || 9.151 ||
Out of the estate the Brāhmaṇa shall take three shares; the son of the Kṣatriya mother two shares; the son of the Vaiśya mother a share and a half; and the son of the Śūdra mother one share. [Manu Smriti 9.151]
If the son is of Shudra women, the son doesn't inherit the property directly. He shall take what his father gives. So, it depends on what father thinks of the son. If he considers him as a son, he is entitled to the property and bears family name. He will be counted as son.
brāhmaṇakṣatriyaviśāṃ śūdrāputro na rikthabhāk |
yadevāsya pitā dadyāt tadevāsya dhanaṃ bhavet || 9.155 ||
Of the Brāhmaṇa, the Kṣatriya and the Vaiśya, the son born of a Śūdra wife is not an inheritor of property; his property shall consist of whatever his father may give to him. [Manu Smriti 9.155]
We can say that legitimate son is still counted as a son (putra) and authorized to perform funeral rites.
Can a stranger of same varna and gotra perform the obsequies?
No direct mention of a stranger of same gotra. But the list contains sapinda and Samanodaka progeny. Sapinda is any person of seven generations* in direct line of ascent or descent. In the absence of Sapiṇḍa, Samānodaka progeny can perform the rites. He is any person in direct line of ascent or descent and the relationship extends to fourteen generations. Same gotra is inherited from generation to generation. More info about Sapiṇḍa and Samānodaka on wisdomlib.org
If we check, there is a possibility that the same person having same gotra and varna as us could be related somewhere in seven or at least fourteen generations. He might have stranger now. But if dug deep, the line could match somewhere. The pundit might have said this keeping this in mind.
What if no authorized person is present?
In the worst case if there are no relatives, friends of any kind to perform the funeral, a king can also perform rites and offer shraadhha. A King is a relative of all. There is an instance listed in the subsequent chapters of Garuda Purana itself where a king named Babhruvahana who ruled Anga. He performed prescribed rites and relieved a ghost. After the performance of the rites, the ghost got a new golden body.