Usually the villagers and/or families in peril knew precisely where their vampire's grave was located. It was generally (and tragically) a deceased family member.
Occasionally an area would be threatened by an unknown blood-sucker. Steps could be taken to locate the grave (like releasing ravens to find it), but in the meantime, the best that the people could do was hope to keep the creature away.
Much of our modern vampire lore comes from Bram Stoker. He did his research too. He took reams of disparate folklore from around the world, then picked and mixed what would ultimately end up in Dracula.
He enriched it with several inventions of his own. Vampires have no reflections in mirrors, because Bram Stoker wanted something to indicate visually that they had no soul.
He also took a brief mention of garlic and made it the vegetable weapon of choice against the vampiric undead. He could just as easily have gone for turmeric. That herb was mentioned in the same Roma folklore from which he lifted the notion of garlic.
But then garlic was more common in both Britain and Ireland, while turmeric (aka Indian Saffron) could be expensive to acquire. Maybe Stoker wanted to give his human readers a fighting chance! Yet it's never explained why garlic (or turmeric) would repel the undead.
A clue could lie in the fact that garlic is a very healthy food to eat. Its properties render it a strong favorite for nutritionists today. Historically, it was also viewed as a kind of 'cure-all'. If it was that good for the body, then it could be great for the soul too.
For that reason, the Classical Age Greeks left cloves of it at cross-roads, so that the Goddess Hecate could snack on it. Shop-keepers in India would hang it up to ward off evil spirits. And, if Pliny is to be believed, the ancient Egyptians worshiped garlic and onions as practical deities.
These traditions trickled into Europe with the Roma, then attached themselves to warding away vampires too. But, in truth, garlic would have to be a pretty good cure-all to combat actually being dead. I doubt a single clove is going to cut it.
Turmeric and garlic were just a couple amongst a myriad of protections to ward away vampires. Another included giving them a mirror. The creatures were so self-absorbed, they'd become enthralled by their own reflection. Their erstwhile victim could then make a clean getaway.
Alternatively, rice could be scattered on the floor. The vampire would become overcome by the need to count them. A whole night could pass in safety, if you just kept adding more dried rice to occupy the undead.
I don't recall any of this turning up in Twilight.