Going into battle inevitably brings to the soldier's mind the reality of death. A good soldier is willing to lay down his life for his friends, sacrificing his good for the good of all.
World War I was no exception and many soldiers went into battle with God on their mind, knowing they may meet him sooner than expected.
Here is a "Soldier's Prayer" as printed in a book entitled The Power of Prayer, published in 1920, along with a brief explanation.