A freehold is where you own the house, the land, and the right to dwell in said land in perpetuity.
A leasehold however allows you to dwell in a flat(for example) for a defined time (99-125 years is popular) you agree to maintain the internal spaces (typically from the plaster inwards). You will pay a "ground rent" for the right to use the land that your flat is located on. In return the freeholder (the person/company) that owns the whole building and the land, is responsible for the maintenance and upkeep of the fabric of the building. They are allowed to issue a "service charge" to recover the reasonable costs of upkeep and repair.
Crucially you never own the "fabric" of the building, or the supporting land.
For leasehold house, then its very simple, the leaseholder can buy the freehold. Or the freeholder can make an offer to the leaseholder.
For a block of flats, its a bit more complex. If a majority of the leaseholders club together, they can buy the freehold, and create their own management company.
This sets out in more detail how and when things can happen: https://www.lease-advice.org/advice-guide/houses-qualificati...
The recent scandal about doubling ground rents can be rectified if the leaseholder buys the freehold, but that is expensive, especially as the houses are effectively unmortgageable
You say that it "comes" as if it was a universal constant, not affected by parties that sign the contract. I'm confused - are transactions involving land somehow forbidden by law?