The real answer
No-one knows. It is possible that Vampires are susceptible to things that smell badly, and they have been known to be susceptible to leeks and spring onions as well as garlic.
Update:
Garlic is a strong natural anti-biotic which kills most infections, with all but the exception of Russian vampire beliefs, vampires are created by an infection of the blood
Silver, holy objects, salt and garlic
Garlic and a tin foil helmet worked for me.
holding cell with crosses and garlic , which are common vampire weaknesses
yes garlic prevent so many sicknesses
garlic by candlelight
Garlic and communion wafers
Give it a mint.
It is said that vampires are allergic to garlic, although I disagree.
Garlic Garlic Yeah... the garlic thing was a red herring, probably planted by vampires to throw people off.
Avoid being alone in dark places and always carry garlic or wear a protective amulet. Stay indoors during the night, and if you must go out, always travel with a friend. Additionally, keeping a wooden stake and a vial of holy water nearby could help protect you from potential vampire attacks.
The main objects that appear in vampire folklore, likely to ward off a vampire, are: garlic and garlic flowers, a crucifix and holy water. But, it is interesting to note that the vampire Lestat, in The Vampire Chronicles, rather liked looking at crucifixes!
Carry Garlic with you all the time