There is no question that [war][1], [self-defense][2], official executions and certain other cases of [para-Halachic killings][3] are either sanctioned, required, or otherwise [allowed (and even rewarded) after the fact][4].

The questions as to why are not answered in a generality; there has been much discussion about each case, with separate explanations for each.

As to your question relating to the prohibition against murder, the answer is that [this is a general rule about taking an innocent life without cause][5].


  [1]: http://www.mechon-mamre.org/p/pt/pt0431.htm#1
  [2]: http://www.mechon-mamre.org/i/b209.htm#7
  [3]: http://en.wikipedia.org/wiki/Yael
  [4]: http://www.mechon-mamre.org/p/pt/pt0425.htm#1
  [5]: http://www.mechon-mamre.org/i/b501.htm#1