The drug may end up in the manure, and the parasites may encounter it there at a marginally-lethal dose. When the parasite progresses further in its life cycle, its offspring may be resistant when they infect the next livestock animal.
Most parasites have a life-cycle that includes time spent outside the preferred host animal, including in zoonotic species that may not have symptomatic infections. They may acquire resistance in any stage, in any place they encountered the drug.
It obviously cannot. But the issue isn't giving it to animals without any parasites, it is in giving it to animals with parasites but that do not need the anti-parasitic in order to recover. Once you have determined that the animal is sick enough to need treatment and that the sickness is most likely caused by the parasites, then you can make the decision that the risk of furthering resistance is outweighed by the need to treat the animal. If you have determined that there is no chance the animal has parasites, then there's no risk of furthering resistance but also no need to give the treatment.
In nature, both the antiparasitic and the parasite will have a tendency to end up in places that you don't necessarily want them to be for the purposes of motivated hypothetical reasoning.