The stated reason is because pigs are considered unclean because they'll live in conditions we consider dirty, and will eat things we consider unclean.
It can be very tempting to look at ways that modern beliefs and practices overlap with historical ones and find ways that make them "make sense" from a modern perspective. This can make it harder to understand what people actually believed, or see the framework they were using, pushing the "oddness" somewhere else, like a bubble under a piece of plastic.
For parasites, we think of pork as carriers of parasites in the modern world because our supply chain has eliminated them from other commonly eaten meats.
This lines up with 2/3 of abrahamic religions having a prohibition against pork: they must have gotten the right answer for the wrong reason.
Except in the times those religions were developed pigs weren't greater vectors than other animals.
There were also other contemporaneous cultures that didn't have that prohibition despite very similar circumstances. If it were a food safety issue we would expect to see other cultures have the same prohibition. Similar problems have similar solutions after all.
https://archaeology.org/issues/march-april-2025/letters-from/on-the-origin-of-the-pork-taboo/