Almost all of law is based on the 'why'. If you kill someone, it starts to really matter 'why'. On purpose? By accident? For profit? All very different scenarios, and treated differently under the law.
Right - guilty mind. "Why" matters.
I did not say that "why" does not matter at all. I said that if you have the right to do X, you can do so for whatever reason you want. Killing someone is something you normally do not have the right to do, but the law makes exceptions under certain extraordinary circumstances. That is, motive can make something permissible that otherwise would be forbidden, but it cannot (per natural rights, not necessarily per the legal system) make something forbidden which is permissible. I have the right to drive people around in my car, or let them sleep in my house, or eat my food, etc. I can exercise those rights, or refrain from exercising them, for any reason I want, or for no reason at all. I do not have the right to shoot someone, or break into their house, or physically restrain them, but the law may decide that I am justified in doing so in rare situations.