Worms are dogs with no legs, and are needed for two achievements!
(I named him Dragon, because I'm always 'dragging' him around!)
This is how his DNA looks
You're interested in the highlighted bit.
These pairs represent which legs will be missing. The first pair is the front left leg, second is front right leg, third is back left leg, fourth is back right leg.
Missing legs are a recessive trait, so if a pair is "aa" then the dog will be missing that leg.
If a pair is "Aa" or "aA" then the dog is carrying the recessive gene. It will still have the leg, but it also has a chance to produce offspring that do not. Your chances increase if bred with another dog with the recessive gene.
This dog has the recessive gene for the missing back left leg, but still has all of his legs.
With all of this in mind, in order to get a "worm" you need every single one of those to be "aa"
The easiest way to do so would be to look for dogs with the recessive gene and breed each missing leg individually, and then breed the results together to get a dog with two missing legs... then three... then all four.
The only way to get this recessive trait is through random mutation in the breeding simulator. The more generations you breed, the more these mutations accumulate, and the more likely you are to see it happen.
Just like I said with wings, food has no impact whatsoever on whether or not your dogs will have missing limbs. The only way a dog can get missing limbs is through the breeding simulator, they will never occur through pupation.
Whether or not dogs have extra limbs uses a different game mechanic entirely, and foods that affect leg number are referencing the amount of extra legs, not the amount of missing ones.