A president who calls journalists the “enemy of the people” has accused news organizations of undermining a military effort that many Americans oppose.