When a soldier commits an offense against military law by either failing to follow a command or carry out a policy how is the offending soldier punished?
That all depends on two things. One is it a time of war or peace and 2 how bad was the crime.
The military has some punishments that are dealt with right with the company commander called a Article 15 that can take away rank, pay or both. This is a harsh thing at company level because all your team mates know about it and know that you did something against policy or failed to follow a command or rule. Your fellow team mates will wonder how trust worthy you are from there and it restarts your time for that good conduct medal.
If the offense is more severe you can be court martial-ed and then be kicked out of the military, imprisoned or worse.