Basically there are two problems to address: first - bed inclination and second - uneven bed surface.
There are different algorithms dealing with one or both problems.
Most specialists insist that bed should be flat and most people use glass as the top to achieve this. And this eliminates second problem and require to solve only the first one.
To find bed inclination - autolevel algorithm usually do three points test and get transformation matrix. This matrix then used to transform XY motion to be parallel to the surface.
For uneven bed surface more complex algorithms used. But usually bilinear mesh used that could be looked as the whole square surface subdivided into smaller ones with individual inclinations. Basically algorithm from XY coordinates determines the sub-square and then applies corresponded transformation for it's inclination.
The transformation fade out with the Z going up and usually applied within first 10mm over the bed level.
There is UBL (Universal Bed Leveling) algorithm that deals with two problems simultaneously. Only once it probes the whole bed with many points to produce two dimensional mesh to address second problem.
And for each next auto level it does three points test to find the whole bed inclination. Then it combines measured inclination with the mesh information stored in memory. UBL assumes that surface do not change but only it's inclination could change.
In all cases this is all about to guarantee that the first levels of filament will lay on the bed evenly and will stick to it.