Murder as a legal concept is a bit more complex than you portray. Check out
https://www.law.cornell.edu/wex/murder