Unfortunately it is not possible to permanently buy a domain name, however, firstly you will need to register it with a domain name registrar. This is a company that is authorized to manage the reservation of domain names on the internet. You can perform your domain search here: https://encode.host/cart.php?a=add&domain=register
When you register the domain name, you will be able to use it for a specific period of time, typically between one to ten years. Once this is on your account, you can then renew your registration to continue using the domain name each year.
Why can't I buy a domain forever?
You cannot buy a domain name forever because the system for managing domain names is set up on a rental model, where you are essentially renting the use of the domain name for a specific period of time.
There is a lot of technical infrastructure behind the DNS system that needs to be maintained for your domain to work. By utilising a rental model, this ensures that the system will continue to operate.
After your registration period expires, you can choose to renew your registration to continue using the domain, or let it expire and be available for someone else to register.