The addition of alcohols to aldehydes and ketones to form hemiacetals and acetals involves nucleophilic addition followed by a dehydration step. Initially, the lone pair on the alcohol's oxygen attacks the electrophilic carbonyl carbon, resulting in the formation of a tetrahedral intermediate. Proton transfer within the intermediate gives rise to a hemiacetal. In acid-catalyzed conditions, a second molecule of alcohol can react with the hemiacetal, leading to another nucleophilic addition and subsequent loss of water to form an acetal. The presence of an acid catalyst is crucial to protonate the oxygen atoms, making them good leaving groups and activating the carbonyl for attack.