Roundworms have a direct life cycle. There is no need for an intermediary host,though earthworms can harbor the eggs, it is not the most common route.
Roundworms mature in the gut, then lay eggs which are carried out with the fecal material. The fecal material is eaten during scratching and thus the next bird infected. It takes about 3 weeks for the cycle to complete again, meaning the eggs develop into adult worms that lay eggs.
That means worm again after 3 weeks (usually stated at 30 days) and clean your litter up to get rid of the worm eggs. If it is a light infestation, worming twice should be enough. If you have a heavier infestation, or litter management is more difficult, some recommend a monthly maintenance worming.
Be aware that Wazine is not FDA approved for laying hens (ie hens who lay eggs for human consumption on the market). If you are treating your birds for your own personal use, you don't have to worry about it. Worm them. Otherwise, you should wait for about 17 days after the last worming before sharing/selling eggs to avoid any potential residue in the eggs. (For personal use, piperazine (Wazine) is used for human worming, and the amount you get from an egg is tiny...I've eaten my eggs with no ill effect...but I don't sell them until cleared).
Roundworms are generally species specific, though some can overlap certain species, but the goats can't get the chicken worms nor vice versa.
The 2 roosters could be infected, but with your set up, and if you aren't seeing evidence in the roosters (showing heavy load), then I would wait until the goats have birthed, then take care of both sides again.
Wazine (piperazine) treats roundworms only.
I see no recommendation of Wazine for goats, so you should use Safeguard (fenbendazole) goat wormer when you are ready to worm the goat side...it would rid roundworms and most other types in the goats and the chickens. Safeguard has a broader spectrum of treatment, so likely would be a better choice for the goats who can harbor different roundworm species at the same time.
Safeguard is not approved for poultry in the US (though I believe it is in the UK with no pull time for small flocks), so you would have to follow a pull time before sale/sharing of eggs. Safeguard is more of a one time treatment seasonally while Wazine requires multiple dosages....remembering that the life cycle of the roundworm is about 3 weeks.
If you have seen evidence, it does mean those hens have a heavy load and all have infestation. Chickens can harbor (and do) a low level infestation, but heavier loads cause poor nutrition uptake resulting in a greatly weakened bird.
Good luck with your flock.
LofMc
http://parasitipedia.net/index.php?option=com_content&view=article&id=2561&Itemid=2842
https://vet.osu.edu/sites/vet.osu.edu/files/documents/extension/Egg residue considerations during the treatment of backyard poultry 2015.pdf