Some Democrats said President Trump’s ban was an attempt to control the press and distract voters as Republicans face deep challenges in the midterm elections.