God gave permission to the Israelites to defend themselves, in their own home, against someone who broke in and hurt them. If, in trying to defend himself, that perpetrator lost his life--at night--then the homeowner wa blameles..
I am Jehovah--I do not change.