Quats (also known as cationic surfactants) and cationic polymers remain on the hair via electrostatic interactions.
This positive/negative interaction prevents them from being removed. On hair they coat the fibers and counteract the problem characteristics.