Tuesday’s elections showed that President Trump’s excesses could fuel a Democratic takeover of the House next year.