I don't know the specifics of how the system works, but from what I understand, it rates certain actions with a score, then that score slowly degrades. The POTG is the highest SPIKE of this score, so let's assume a kill is 10 points, an assist is 5 points, and that it degrades at 1 point per second.
A Soldier76 uses his ult and starts gunning people down. He kills one guy (10) but two seconds pass before he kills the next (18), followed by another that he nearly kills but then has to reload, allowing an ally McCree to get the killing blow two more seconds later (21).
A Junkrat attacks a point and his bombs tickle five enemies for some damage. He then uses his riptire, and gets two kills instantly (20). At nearly the same time, his team is coming in from the other side and kills the three remaining giving him assists (34)
Torbjorn is sitting in the back on his turret. The enemies come in and the turret starts shooting, and due to the enemies either moving forward or backing off, the turret at some point has hit all of them. As they push Torbjorn uses Molten Core, and his rockets obliterate one enemy, gets the killing blow on another, scatters the rest for the rest of the team to pick off, allowing them to get a team kill over the next four seconds. Since the turret at some point had hit all six of them, he would get 10+10+5+5+5+5-4 (36) and giving him the play of the game for that match.
This is just breaking it down to the basics, there are other things taken into account headshots, damage done, whether the enemy you hit is on the ground or in the air, shutting down an in progress ult, etc.