(Note: I don't have a background in political science.)
Imagine playing a "vote-getting" game. It's a two-player game, and you get votes by stating your positions on various policy matters.
You and your opponent play a round, and let's say you lose with only 20% of the vote.
Your goal is to win. You're not wedded to any particular policies; everything is negotiable. Because if you don't win then none of your policies can be implemented.
So you start tweaking. Make adjustments with the goal of moving that 20% up to 50%. It's tricky, because these adjustments aren't monotone functions, and the levers you pull don't all move independently. But move them you can, and the results can be observed.
Now imagine you and your opponent do this repeatedly. Each of you is trying to get to 50%, each of you feels free to adjust your policies to move the vote.
Eventually you will both hover around 50%.
In real life, political parties do have policy positions which are sacrosanct, but many can be adjusted. The media disseminates their messaging and debates it in the public forum, and polling organisations continuously check how voters feel. In the United States this information feedback loop is very well developed.