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.