Old autopilots did exactly that, in addition to keeping a predefined climb/sink rate (long ascents/descents are really boring to do manually in small aircraft).
New autopilots in commercial airliners can do many things (follow GPS tracks or radio navigation waypoints, control engine throttle, line up and bring the airplane 50-100ft over the runway etc) but they never do collision avoidance, landings or terrain mapping.
Airliners also have alarms for low altitude (most have radar altimeters) but they prompt the pilot for action, they're not supposed to avoid anything on their own. Apparently Tesla doesn't even do that.
Modern airliners can and sometimes do do automatic landings [1] [2] [3] [4]. It's done when visibility is very poor. If it is not required, most pilots prefer manual landing. It's less work. The autoland system is more complicated to set up, and is more work to monitor in order to take over if something goes wrong. But when the visibility is low enough, many airlines require their pilots to use it.
New autopilots in commercial airliners can do many things (follow GPS tracks or radio navigation waypoints, control engine throttle, line up and bring the airplane 50-100ft over the runway etc) but they never do collision avoidance, landings or terrain mapping. Airliners also have alarms for low altitude (most have radar altimeters) but they prompt the pilot for action, they're not supposed to avoid anything on their own. Apparently Tesla doesn't even do that.