There are organizations that are called registries that manage each TLD option. When you register domain names, you would first visit a domain registrar who would in turn check with the registry that manages that TLD to see if the domain is available. If the domain for the TLD you want discovers that it is in fact available, the registry adds it to their registry and gives you access to it. If the domain has already been registered by another user for that TLD, you will be shown during the domain registration process that the domain isn't available.
A great domain name is a concise, easy to type, and memorable URL that reflects your brand or your website’s subject matter. Avoid using hyphens, strings of numbers, or unnecessary words to make it easy for your visitors to remember and find your website. Remember: A great domain name is one that your visitors can type correctly on their first try.