In scriptures, the terms 'sheep and goat' are generic symbols for the righteous and the wicked, respectively. One example being
Zechariah 10:3;
Mine anger was kindled against the shepherds, and I punished the goats: for the LORD of hosts hath visited his flock the house of Judah, and hath made them as his goodly horse in the battle.
The logic that Christ followed concerned the day of judgment. It is written that he spoke to multitudes ever in parables, and in none other way.
And so, just as he used various approaches in expounding the nature of the kingdom of God, one of which choices having been the mustard seed, so it is that the symbolism of beings not human, or any element forming the day judgment, being it victims of the day-the wicked, or benefactors from it--the righteous, their depiction can take on any 'names' apparently arbitrary in the context.
That's why 'sheep and the goats' are perfectly logical terms in that respect, and appropriate in the context, as to what preceded them or what follows.
The symbolism of a 'goat' appears many times in unfavorable contexts concerning those it depicts, portraying them as wayward.
Whereas the symbolism of a sheep is largely about those that are 'obedient' as to be led, albeit not in the right path by blind shepherds, and in which case they fair no better than the 'natural goats', and thereby depicted as having become 'fat'.
Ezekiel 34
And as for you, O my flock, thus saith the Lord GOD; Behold, I judge between cattle and cattle, between the rams and the he goats
And so both the 'goat and the sheep' are used in the bible more often than not, in the context of righteousness.
Isaiah 34:6 [KJV]
The sword of the LORD is filled with blood, it is made fat with fatness, and with the blood of lambs and goats, with the fat of the kidneys of rams: for the LORD hath a sacrifice in Bozrah, and a great slaughter in the land of Idumea.
In these cases, and many that are similar, was the basis for the logic that Christ put forth concerning judgement of 'sheep and the goats come that day...
I hope that helps as to the relevance of these terms in the context.