I get asked this question a fair bit, and have written several blog posts on it- one on good options in 22 pistols, one on good options for concealed carry, what features to look for in a concealed carry gun and a post explaining why smaller guns are less pleasant to shoot,
If you are reading this and are relatively new to firearms, I suggest you take the time to review the basic rules of gun safety and read a bit about why using a gun in self-defense should be a last resort.
So, what sort of handgun is right for you depends entirely on your motivation and your desired purpose. Are you looking to build skills? Want something for home defense? Have the goal of shooting in competitions? Want a gun for concealed carry? How much are you willing to practice? Depending on your answer to those questions will depend on what handguns are best suited for your purpose.
Being able to shoot handguns well is a skill that has to be developed. I liken it to yoga or soccer or any sport or activity that requires coordination and your muscles to be used in a certain way. If you go to a few yoga classes you'll have the basics down, but you will probably still need some reminders from the instructor on proper positioning. You'll know the various forms but maybe won't be very fluid or have the range of motion as a person who does it regularly. The more advanced positions will likely be out of your grasp. If you take 6 months off from doing yoga and go back, there's a bit of a learning curve again to get back up to speed.
The same goes for shooting handguns. If you go to the range a few times you'll have the basics down, which is safe handling. You won't be smooth, you won't be fast, you won't be accurate. It takes times to hone your skills to achieve those things. If you keep with it, your skills will increase and you'll get more accurate, smoother and faster. But if you only practice twice a year, you will likely never build skills past being safe. But for some people, being safe is enough.
As an example I recently ran a shooting course with people who are very good shooters. They range from "practices 3 times a week and shoots competitions" to "shoots a few times a year". Our shooter that practices the most cleared a course in 29 seconds. The shooter that practices the least took more than 80 seconds. They are both very accurate shooters, but turning slow and accurate into fast and accurate takes a lot of practice.
Along with that, more powerful guns take more skill to shoot. If you don't plan to shoot a lot, at least at first, then choosing a powerful gun may not be the best choice. You increase the chance that you won't build skills with occasional practice, and practice will be more expensive. So if you are only planning on shooting occasionally, I would consider a 22 handgun. You'll likely be more accurate with it with occasional shooting. In fact, my recent experience showed that everyone shoots a 22 handgun faster and more accurately than more powerful guns, regardless of skill level. You can purchase more powerful ammo for a 22 for defensive purposes if you want to use a gun for that. They even make reliable 22's that are of a suitable size for concealed carry.
If you are planning on taking up shooting as a hobby, again, a 22 handgun makes sense as your first gun for reasons of economics. Right now 22 ammo is about $20 - $25 per 500. The least expensive centerfire round, 9mm runs about $12-$14 a box, which is only 50 rounds. Except right now it's mostly sold out due to panic buying. You can afford to shoot 7 or 8 times as often with a 22 than a 9mm. If you look at other rounds like 38 special or 45 acp, you can shoot 10 times as much or more with a 22. You can afford to build up skills with a 22. Even though I have a number of more powerful guns, I still shoot more 22 than anything else, it's an ideal way to keep up skills without it getting too expensive.
If you are going to buy a gun, shoot it a few times and toss it in a drawer in case you ever need it, then a more powerful gun is a good choice. If you aren't going to practice and develop skills and hone your accuracy, you may as well shoot something that is more powerful. Select 9mm or a revolver that is simple to use, so you don't end up fumbling with the controls if you ever need to use it for self defense. It's not optimal, but it's a lot better off than not having a gun should you ever need one.
So I guess my recommendation is buy a decent 22 handgun as your first gun. Shoot 2,000 rounds through it and build up skills. Then you can choose to keep it and you'll have a better idea about what you are looking for in a more powerful gun. Or you can trade it in on a more powerful gun since guns hold their value well over time. The depreciation is going to be much less than the cost of 2,000 rounds in a more powerful caliber. And if you shoot 200 rounds at each range visit, that's only 10 range visits. That'll cost you $80 in ammo in a 22 or $700 or more in a 9mm. If you buy a 22 handgun for $300 and get even $200 in trade on another gun, the math works itself out in your favor by a lot.
The last bit of advice I have is to shop at an independently owned local shop. You'll get much better service and you'll have people who know the products there. You don't get those at a big box store.
Stay safe out there!