AFM tips work by interacting with the surface of a sample via various forces, such as van der Waals forces, electrostatic forces, and mechanical forces. As the tip scans the surface, the cantilever bends or deflects, and this deflection is measured using a laser beam reflected off the cantilever. The resulting data is then processed to create detailed images of the surface at the nanoscale.