If you want to register a domain name (e.g. example.com) you will need to use a domain name registrar.
Popular registrars include: NameCheap, NameSilo, and Hover.
Prices vary depending on the domain extension. A ".com" domain name is usually around $10 per year.
Most domain name registrars also offer web hosting. And most web hosting providers offer domain name registration.
So what's the difference, you ask?
Domain Name Registrar vs. Web Hosting Provider
When purchase a domain name with a web hosting provider like Hostgator, you can only register a domain name when purchasing web hosting; Hostgator does not offer domain name registration as a standalone service.
Meanwhile a domain name registrar like NameCheap allows you to purchase as many domain names as you want. They also offer web hosting, but you don't need to purchase their web hosting services in order to register domain names.
Registrars make it easy to transfer your domain name to a competiting registrar. You can also transfer ownership of your domain name to another person or company.
If you register your domain name with a web hosting provider like Bluehost and you later decide to leave that provider, you will need to transfer your domain name to your new web host or a domain name registrar. Web hosting companies are supposed to comply with this request, but sometimes they make it difficult to leave and they may charge exorbitant fees for this service (even though they shouldn't be charging anything at all).
I recommend registering your domain name(s) using a registrar. If you use a service like NameCheap, you can also purchase web hosting at the same time. However, it might not be advisable to buy your domain name from the same company that hosts you web site. (If you somehow run afoul of your web hosting agreement, ownership of your domain name could be put at risk.)
Before you can purchase a domain name you need to check if its available. Sometimes people register domain names with the intention of selling them. And sometimes those people work with brokers that list domains for sale via domain name registrars. So if you go to NameCheap and search for a domain name like khsfkjhksfhs.com, you will probably be able to purchase it for the usually price (under 10 bucks a year). But if someone is re-selling a domain name they already own, they can charge anything they want (hundred or thousands or even millions of dollars).
Reminder: People generally refer to domain names in terms of ownership, but really you can only rent/lease a domain name from the international group that controls and regulates domain names (ICANN).