You can go online to any firearms based website or blog, ask any firearms "expert" or enthusiast, "what's the best option for a home defense weapon?" and you'll receive a huge array of responses. You'll get input on weapons, brands, ammo types and calibers, weapon accessories, state and federal laws, ballistic performance, physiological effects, psychological effects, etc. You'll even get some people recommending good attorneys to hire if you get into a shooting situation. The people you ask will morph into lawyers, cops, doctors, engineers, physicists, salesmen and Army Rangers right in front of your eyes, and all at the same time.
I'm not here to flood you with that and I'm not here to make your choice for you. I'm going to let you know what I choose and why it works for me. You can decide if it works for you. Obviously the best weapon for home defense is the weapon you have when the time comes for you to use it.
My personal choice is a Colt M4 Carbine chambered for 5.56x45mm NATO ammunition. I installed quad rails and put a government issue pop-up iron rear aperture sight on the flat top receiver. I installed a Streamlight TLR-1s flashlight (300 lumens) onto the left quad rail using a Magul mount. There is an EOTech XPS 2-2 Holographic Weapon Sight and an EOTech G33 swivel magnifier. I use Magpul 30 round PMags. I replaced the standard grip with a Blackhawk grip with finger grooves. I currently have my two home defense magazines loaded with Black Hills 77gr OTM ammunition.
My reason for choosing this weapon is that I prefer having a weapon that requires less "fine motor" skills and more "gross motor" skills to operate properly. When you're jarred awake by someone beating your door down at 0200, your fine motor skills aren't always going to be there ready to go. You'll still have your gross motor skills, and that's why I currently choose a long gun over a pistol. A pistol is a fine weapon for home defense, especially if you're skilled in pistol shooting, but it does require that you keep your fine motor skills with you through any amount of combat stress, which is easier said than done.
Some will ask about shotguns, and here's my only reason for choosing a rifle over a shotgun. I've got 30 rounds in my weapon while a shotgun likely has ammo in the single digits. I can also load up another 30 round magazine much fast than someone can load another handful of shotgun shells. A shotgun is a great option for home defense, but I have my own reasons for choosing the rifle.
I've personally used the Colt M4 Carbine to clear buildings in training situations and during a combat deployment. I've seen what the 5.56 NATO ammunition is capable of and trust me, it's ugly. I know there is always going to be some politics surrounding the decisions that are made by the higher ups, but we've been using 5.56 NATO since Vietnam. If it didn't do its job, it wouldn't still be in use by our military five decades later. Maybe it would have stuck around for a bit, but not for over fifty years. This round is more than adequate and I've seen it up close and personal.
I think the last complaint most people have is the possibility of over-penetration with this ammunition. But here is the point I make: ANY suitable self defense ammo is going to penetrate sheetrock like it's paper. Same for your home windows. Same for bedroom doors. No matter what you're shooting, you NEED to ensure that all family and friends are accounted for and preferably BEHIND your firing position. You can ensure this by strategically locating your bedroom between the common area of your home and the other bedrooms, if possible. It makes it easier to shoot an intruder if you have already secured your family in the bedrooms behind you. Again, any self defense ammo is going to penetrate the barriers in your home. I have personally witnessed a .25 caliber round negligently discharged inside a home, and it penetrated a bedroom door, two walls and then embedded itself into a third wall. This is why it's more important to have a weapon that will allow you to have the highest accuracy when fired repeatedly. The M4 Carbine provides that.
You obviously have to evaluate your own situation and obtain the weapon that best fits your needs and abilities. If your budget allows you to only purchase one weapon and you'd like to also carry it in your vehicle, then a pistol is surely more suitable than a long gun. If you like the idea of firing multiple projectiles at once,then you can get that in a shotgun. I've detailed my own choice and my reasons. What is your choice?