Even as the presidential election dominates the country’s attention, Democrats have spent record-breaking sums this year on winning seats in state legislatures, 10 years after a Republican wave gave that party the power to reshape U.S. congressional maps.