

I’m not saying that would never happen, because I’m sure it has. However, most places would have a spare metal detector unit just in case this type of thing happened.
What is probably more likely is that the factory did not have a very frequent test cycle for their metal detector. Which means, the metal detector could have been broken for a long time and nobody noticed it. Given enough time, something is going to happen and the product could have become contaminated with metal shavings.

I have to concede that my experience is entirely a way-too-small sampling of the entire industry, so it’s entirely possible you are right here. However, in my experience, the factories that I’ve been to (granted, not ALL of them) have been incredibly clean and well-maintained and follow very strict guidelines for making sure their product is safe. Obviously, the consequences of delivering a product that is not safe are quite dire (noting the Boar’s Head example and the recent ByHeart recall).
On that note, I never visited the Boar’s Head facility, but one of our customer service reps did and they said it was downright nasty. No wonder they got infected.
By the way, listeria contamination is probably the WORST thing that happen to a food-producing factory. This bacteria is incredibly dangerous and very, very hard to get rid of once detected. I’ve known factories that decided to relocate rather than try to deal with an outbreak.