That's a drastic oversimplification. For one counterexample, consider a prosecutor who believes x but also y. The community agrees on x but not y and consider that a dealbreaker, so the prosecutor is not elected. And this doesn't include issues such as ease of voting and gerrymandering.