All we have are scriptures and texts that could have been a series of meme that built/improved from eachother but lost the common knowledge between the generations that it was fictional.
It is obviously intentionally done to mimic the ritual sacrifice of the two goats on Yom Kippur, the day of atonement. Two goats were presented to the high priest, one was chosen by casting lots to be sacrificed on the altar and the other was cast into the wilderness, purifying the people of Israel of their sins. In the story, Jesus plays the role of both goats.