They have to be exposed to the eggs in feed or fecal matter. Not to be a One Note Nellie, but raw garlic kills roundworms and their eggs, too.
http://www.associatedcontent.com/article/1806628/worming_chickens_naturally_pg2.html?cat=5

http://www.associatedcontent.com/article/1806628/worming_chickens_naturally_pg2.html?cat=5