A dominant performance by Democrats in this week’s midterm elections created a political earthquake, shifting the balance of power in Washington, D.C. and offering a clear view of voter frustration with President Trump and his party.