Some pups get them in- utero, but usually the breeders test and treat for that. There are several types of worms, all of them gross and disgusting. They can get them from fleas who carry eggs of one particular worm and when they bite the dog the larvae are transmitted to the dog. Sometimes copraphagic dogs (dogs who eat poo) will get them from said poo. If your dog hunts and eats part of their kill or for instance a whole squirrel, they can contract worms from whatever they ate. Easily treated, don't freak out! The thought of them is worse that the reality of them!