That is to say, unless the election is a dead heat and no one can say who won they will always go with the candidate who gets more votes.
If the legislature goes against the "winning" candidate it will quickly find its power to decide elections stripped away.
The same principle relates to the Electoral College and the idea that state legislatures should pick US Senators.
If electors or state legislators decided to go against the election returns, they'd lose the "power" to "decide."
In 1858, Republican Abe Lincoln won 50.6% of the vote (either that’s the total % GOP legislative candidates got or there was a separate preference referendum) but the leg majority remained rat and they voted along party lines to reelect Douglas, the 17 amendment wasn’t passed for another 50 years.