(Devarim 20:3) "And he shall say to them "Hear, O Israel, who is the man that is fearful and faint-hearted...and the officers shall continue": Why was all this stated? So the cities of Israel should not be desolate. As Rabban Yochanan ben Zakai has said: Come and see how G-d cares for human dignity.When one [soldier] returns, the others would say "maybe he has just built a house" or "maybe he has betrothed a woman". All had to bring proof besides the fearful one whose situation was evident. He heard shields clashing and was scared, blaring trumpets and was shaken, he sees swords being wielded and loses control of his bodily functions.
Provisions for Soldiers Overcome by Fear in Battle
Sifrei Devarim 192:1