The Hib vaccine works by stimulating the immune system to produce antibodies that can target and neutralize the bacteria. It is usually administered as a series of shots, starting at 2 months of age, followed by additional doses at 4 months, 6 months (if needed), and a booster dose at 12-15 months.