That's because an increasing segment of the population were those that survived the diseases and hence were immune to them. This is the way diseases usually evolve, no magic here. If you hit it with a vaccination campaign on its way down, you can even eradicate it before of blossoms again when a new crop of fresh victims grows up. The Spanish flue died out on it's own because it was too virulent, thus infected too many people so that there were soon too few susceptible people left. From an epidemiological POW it was not much different from the annual flue epidemic making its round in the Northern hemisphere every autumn. The reason it lasted as long as it did was because of the horrible condition in the trenches on the Western front. You really ought to read up on basic epidemiology.