It becomes more technical, if one is specifically interested in the methods used by SpaceX. But there are some overviews that describe the general idea. Here is one presentation by Behçet Açıkmese: https://nescacademy.nasa.gov/video/eda2b96bddf945629be2c9d2e...
Note that before joining SpaceX to lead their autonomous landing software development, Lars Blackmore worked at JPL, where together with Behçet Açıkmese they developed the autonomous precision landing algorithms based on real time optimization methods. So, even though SpaceX has undoubtedly developed additional nuances to match their needs and capabilities, they were building on this prior work at JPL.