I've not kept track, but it seems that in all the cases I can remember the win was given to the pitcher with the lowest ERA for the game, with innings used as the tiebreaker. That would fit your scenario. I agree that it's not a good way to choose the winning pitcher.