It sounds like you did not have your doors locked. That simple step would have been better than pepper spray, a taser, or a firearm.
It's not clear where this guy came inside since everything was locked by the time the police arrived and we checked them together, but it's not like I routinely just go to bed with windows open and doors unlocked. But yes, it's logical to assume that something in my one-level house wasn't properly secured that night and by an incredible stroke of bad luck, he just happened to pick MY house that night. I have since gotten a security system that will sound an alarm if any door or window is opened.
However the same thing could've happened in the middle of the day. How often do we have a window open to get some air? Or leave a door open from the garage while we're mowing the grass? (Actually, now I routinely lock the door when I may be occupied with yard work, which still seems rather paranoid to me.) Or the door is unlocked while your child is playing the backyard or in front of the house? And do we all have bump-proof locks on all the doors? Or maybe this guy could've approached me in my garage while the garage door is up?
As I mentioned earlier, life has a inconvenient way of not playing out exactly like we imagine in our minds.