This imagery exists because the struggle to overcome the demands of the self-centered ego is much the same in soldiers as in real spiritual seekers. Soldiers must overcome their own natural desires for freedom, comfort and safety. They must learn to place the welfare of the group above their own. Marching teaches soldiers to ignore their own ideas and feelings and obey orders. The aim is to train troops who can stay awake all night in rain and cold and then march into enemy fire.
Sacred dance has a very similar aim.
Real spiritual work cannot be limited to meditating on a pillow in the comfort and safety of your own home. The difference between the soldier and the seeker lies in whom you are seeking to obey, and why. The aim of spiritual training is to enable you to hear and to obey the voice of the truth that is hidden within you. That is the great question, over which every argument and war that ever was was fought. The Nazis did what they did because they believed that what they were doing was true.