In Major League Baseball, the official scorer credits one pitcher with the win and one with the loss. Rule 9.17 gives the win to “that pitcher whose team assumes a lead” while he is pitching, with some exceptions. A starting pitcher usually has to complete five innings to get it. The loss goes to the pitcher who is “responsible for the run that gives the winning team a lead.”
Rule 9.12 does the same for mistakes in the field. An error is “a statistic charged against a fielder” whose misplay helped the other team.
The win is a famous number and a disputed one. In 2020 Matt Snyder of CBS Sports called it the “dumbest stat in all of sports.” In one game he described, a relief pitcher who recorded one out got the win. The starter threw four scoreless innings and did not get it.