Seemingly, the people were telling King David that the enemy is totally focused on defeating King David personally. As Achitofel said (17,1), “I will strike down only the king.” Therefore, if King David is present in the field of war, he will give additional motivation and vigor to his enemies. If the army flees, David's enemies will come chasing with fury. If David is present the enemy will fight with all of their gusto which will make them harder to defeat. Thus, the people urged King David to stay in the city to help through his prayer.
The Chasam Sofer offers another insight by pondering the general question - is it better for our tzadikim and talmidei chachamim to be with the troops in the theater war? By doing so their merits would help protect the troops. Or, perhaps, they should be back in the shul and yeshiva in the cities with complete peace of mind so that they can focus on their prayers and study to maximize the merits that will accrue as a protection for the troops.
The Chasam Sofer says that the answer is derived from Tehillim 20 which we say every day. Chazal teach us that King David said this prayer when Yoav went out to war. In it King David pleads, “May Hashem answer you on the day of distress, may the Name of Yaakov's G-d make you impregnable. May Hashem dispatch help from the Sanctuary, and support you from Zion.” Rashi explains that King David offered this prayer, not with the people in the theater of the war, but rather in Jerusalem as the verse in our chapter says, “It is better if you help us from the city.”