To me garlic acts as an anti-bacterial, so if it prevents getting worms then it would work as worms to me come from bacteria. If the gut is healthy then worms won't be there. Sounds simple but I don't think it's that complicated. Apple cider vinegar is also a preventative it helps to neutralise the gut. If you have worms you have to chemically remove them, so best not to get them in the first place.