Candidates pick positions on a left-right axis; voters back the nearest one. Poll, split the vote, find the median voter.
Downs spatial model. Each voter has an ideal point x on a line from -1 (left) to +1 (right) and votes for the candidate whose position is closest. With candidates at p1<p2<..., the dividing points are the midpoints b=(pi+p(i+1))/2, so a candidate's share is F(b_right)-F(b_left), where F is the voters' cumulative distribution (a mix of two normals here).
Median voter theorem. With two candidates and one-dimensional preferences, the share of A is F((a+b)/2); it is pushed up by moving toward the opponent, so both converge on the median voter's position.
Polls. A random sample of n voters estimates a share p with standard error sqrt(p(1-p)/n); the 95% margin is 1.96 of those. About 1 poll in 20 misses by more than its margin.
Honest simplifications. One issue dimension, everyone votes, nobody votes strategically, candidates do not shift. Real elections have many issues, turnout effects, party loyalty and rules (runoffs, proportionality) that change results. This is a teaching model, not a forecast.