The prohibition against killing (Exodus 20:13) actually means murder, which is quite different than the sort of killing that goes on in the course of a battle. A distinction between murder and death in battle is apparent in David’s statement in 1 Kings 2:5. A whole range of circumstances that lead to death will be dealt with in 1 Kings 21:12–27. These laws make it clear that the sixth commandment is a general statement that requires expansion.
Elwell, Walter A. Evangelical Commentary on the Bible. Vol. 3. Grand Rapids, MI: Baker Book House, 1995. Print. Baker Reference Library.