What are the common ways dogs can get worms? Can I protect my dog and prevent worms instead of deworming?

There are different types of worms and different ways dogs can get them:

Roundworms - via the mother prenatally, or by licking worm eggs off the ground or other surfaces.
Hookworms - by licking worm eggs off the ground or other surfaces, or via the mother's milk.
Whipworms - by licking worm eggs off the ground or other surfaces.
Tapeworms - via swallowing fleas that ate tapeworm eggs.
Heartworms - via bites of infected mosquitos. Mosquitos get infected by biting another dog that already had heartworms.

As you cannot fully protect your dog from mosquito and flea bites, and you do not always control what your dog picks from the ground, there are no 100% effective ways to protect it from worms unfortunately.

Hi peeps.
I have follow up question. Has anyone heard about medications or remedies that would prevent getting worms even if dog has eaten eggs? In contrast to deworming medicines that deal with consequences.
Raphael this was so helpful, thanks! I had no idea how easily dogs can get worms! We got a new puppy just a week ago and hopefully she'll stay worm free.

Andreas, I can be mistaken but there are only some medications to prevent two types of worms - heartworms and whipworms. They have to be given either daily or monthly. They work by killing worm larvae. I don't know their names so you had better consult with a veterinarian. Even if I knew, it would not be safe to give a medication to your dog regularly without a vet's advice.

Cleopatra, welcome to the site. If you have any questions, feel free to ask them, I'll try to help.