Let's use acetone as an example. The reaction involves several steps.
Step 1. Proton abstraction to form a resonance-stabilized enolate ion.
#"HO"^(-) + underbrace("CH"_3"COCCH"_3)_color(red)("acetone") ⇌ underbrace([stackrelcolor (blue)("-")("C")"H"_2"COCH"_3 ⟷ "CH"_2"=C(CH"_3")-"stackrelcolor (blue)("-")("O")])_color(red)("enolate ion") + "H"_2"O"#
Step2. The enolate anion attacks the carbonyl carbon in another acetone molecule.
#"CH"_3"CO" stackrelcolor (blue)("-")("C")"H"_2 + "CH"_3"COCH"_3 → "CH"_3"COCH"_2"C(CH"_3")"_2"-"stackrelcolor (blue)("-")("O")#
Step 3. Protonation of the enolate ion to form an α-hydroxyketone.
#"CH"_3"COCH"_2"C(CH"_3")"_2"-"stackrelcolor (blue)("-")("O") + "H"_2"O" → underbrace("CH"_3"COCH"_2"-C"("CH"_3)_2"-OH")_color(red)("4-hydroxy-4-methylpentan-2-one") + "OH"^-#
Step 4. Dehydration to form an α,β-unsaturated ketone.
#"CH"_3"COCH"_2"-C"("CH"_3)_2"-OH" → underbrace("CH"_3"COCH=C(CH"_3")"_2)_color(red)("4-methylpent-3-en-2-one") + "H"_2"O"#