You have to swallow the eggs. Usually it happens in countries where workers end up pooping in the fields they work and then the eggs are in with the vegetables. If the vegetables aren't washed well you might end up swallowing the eggs. Things that go into making a salad for example.
https://msu.edu/course/zol/316/alumgut.htm
I once saw a little puppy in a pet store puke up a mass of these suckers. They were writhing on the floor like snakes!
I took a semester of parasitology at college a long time ago. The professor was friends with a local doctor and he showed us a huge ascaris worm that was from a little boy that lived in the area. He also told us stories about how he detected that his kids had pinworms. He crept into their bedroom and night and shined a flashlight on their buttholes. He could see the female come out and lay its eggs around the rim! Crazy stuff. That was a fun class.
Pinworms layin eggs!
Pinworms - symptoms, Definition, Description, Demographics, Causes and symptoms, Diagnosis, Treatment
"Adult pinworms live in the large intestines. Males and females are about 5 mm and 10 mm long, respectively, with the diameter of a strand of thread. After copulation, the males die. When the female is ready to lay eggs, she crawls out of the anus, and violently expels the eggs on the skin around the anus. Some of the eggs become airborne and land elsewhere, but the majority stay on the skin of the buttocks. A single female can produce more than 10,000 eggs. After laying her eggs, the female also dies."
Read more:
Pinworms - symptoms, Definition, Description, Demographics, Causes and symptoms, Diagnosis, Treatment