I guess there hasn't been an instructor giving input. I am an instructor and yes you did do a few things wrong. First, and for the rest of your life, never put your finger on the trigger until, and only until, your sights are on the target. That rule alone would have saved you. Next isn't a rule but it is a necessity in self defense - never, never, never cock a gun for self protection. If you are forced to shoot someone you will end up in court. Maybe not for the shooting itself but for sure by the family of the BG you shot.
In court it can be made to look like you wanted to kill the BG since you cocked the hammer. My main self defense gun, S&W 342PD, has an enclosed hammer. I couldn't cock the hammer if I wanted to. We have two other revolvers that have bobbed hammers. Very difficult to cock the hammer. My wife's defense gun has a hammer but she practices only double action. In an emergency I would expect her to act as she trains.
Glad no one was hurt and you didn't end up in jail. I learned a lot of things the hard way - you don't forget those. From now on - shoot safely.