The Apollo LM was developed with a self-landing capability in its software, though in practice the mission commander took over manual control at around 150 meters altitude in all the actual landings. It used a radar altimeter for real-time altitude determination, and was accurate to within about 2 meters at low altitude, which doesn't sound great, but the LM's final descent speed was fairly low. Mission commander Jim Lovell intended to use the automatic landing program on Apollo 13, but that mission didn't get the opportunity to attempt a landing.
Surveyor, likewise, used a radar altimeter; it would come to a halt about 4 meters from the surface and free-fall to touchdown. I'm not sure of its accuracy, but it was probably not too dissimilar from the LM.
Falcon 9 first stage uses GPS for landing guidance, and for barge landings the barge does as well, both trying to steer for an agreed-upon coordinate. It's believed that F9 also uses a radar altimeter, but as far as I know there aren't any public details on it.
I assume that Starship uses essentially the same system as F9.
One little-known case is the gamma-ray altimeter used to trigger retrorockets in the Soyuz descent module at about 3m altitude. This consists of a radiation source and a detector; when enough gamma radiation is reflected to the detector from the surface, solid rockets fire to brake the capsule for the touchdown. Such a detector can't give you accuracy over a wide range of distances without a dangerously large radiation source, but it's extremely simple.