Each region around the world has an entity responsible for domain names with certain endings, like .us for the United States, .uk for the United Kingdom, .de for Germany etc. .com, .org etc. for international entities.
They can then license companies to sell certain domain endings. They are usually ISPs and hosting companies.
There are also restrictions, the US registry responsible for .co.us, .org.us domains ,but they can’t register domains for the UK, Germany or any other country. The same goes the other way round.
There is also an international registrar, responsible for .com etc.
Companies can apply to the registries to be able to sell the domains for that region. Most service providers apply for the rights to sell domains to their customers.
ICANN sits at the top and the regional registrars, such as DENIC take care of the countries or regions then you have the likes of 1&1, Strato or GoDaddy who sell the domains to companies and individuals, registering them through the relevant registrar.
The are also some caveats, only EU based companies and individuals can buy .eu domains, for example and only non-profits can buy an .org domain.