It's specifically the sanitation of the living condition of infants that had the effect, not the general sanitation level of society. Polio was still circulating through the population outside during this time period, but infants were shielded from it during their short window of protection.
But I did find where I got that from, for whatever it's worth, George Carlin:
> When I was a little boy in New York City in the 1940s, we swam in the Hudson River, and it was filled with raw sewage. OK? We swam in raw sewage — you know, to cool off. And at that time, the big fear was polio. Thousands of kids died from polio every year. But you know something? In my neighborhood, no one ever got polio. No one. Ever. You know why? 'Cause we swam in raw sewage.
(from https://www.businessinsider.com/george-carlin-why-we-need-to...)
[edit]: I do wonder if, because I have no reason to doubt it's true, what being exposed to sewage-infested water did is provide some sort of vaccination, by means of exposure to very low levels - insufficient for infection - of pathogens including polio. After all, that kind of analogue process is what early vaccination was.
[edit 2]: that might still be completely off, I mean, reading about it I understand that at the time, 10x as many children would die by accidents, and 3x from cancer.