Fats and oils are triglycerides. Each one is a glycerol backbone connected to three long fatty acid chains by ester bonds. When a strong base like sodium hydroxide or potassium hydroxide is added, hydroxide ions attack the carbonyl carbon of each ester bond.
Chemists call this step nucleophilic acyl substitution. The ester bond breaks, releasing a fatty acid salt, which is soap, and freeing the glycerol backbone. Each triglyceride needs three hydroxide ions to fully react, since it has three ester bonds.
Soap molecules have a useful shape for cleaning. Each one has a long hydrocarbon tail that avoids water and a charged head that attracts water. In water, soap molecules cluster into tiny spheres called micelles, trapping grease inside while the outer surface stays dissolved.
This is how soap lifts away dirt that plain water cannot rinse off. A common misconception is that soap dissolves grease the way sugar dissolves in water. It actually surrounds and suspends the grease so water can carry it away.
Saponification needs heat and enough water to proceed efficiently. Sodium hydroxide produces hard bar soap. Potassium hydroxide produces softer soap often sold in liquid form.
