Starting pitcher ends inning with a 3-1 lead. New inning, relief pitcher gives up two runs for a 3-3 tie. Bottom of that inning we go ahead and finish with a win. Which pitcher gets the W? Seems odd if the relief pitcher who blows the lead would get the W.
Rule 9.17(a) states:
The Official Scorer shall credit as the winning pitcher that pitcher whose team assumes a lead while such pitcher is in the game, or during the inning on offense in which such pitcher is removed from the game, and does not relinquish such lead
[ some exceptions which don't apply here ]
The relief pitcher in your example meets that definition, so they are the winning pitcher. What you're finding here is that wins and losses for pitchers aren't a very good measure of very much at all.
As an aside, as the relief pitcher entered the game in what was a save situation (a lead of no more than 3 runs) and failed to keep the lead, they would be "credited" with a blown save in this example. However, saves are probably an even less meaningful statistic than wins and losses.