Yes it is. When everybody who's susceptible to the disease has either died or got better, it's hard for a bacterium or virus to find a home. So it peters out until a new susceptible population arrives. This is why both smallpox and plague became diseases of childhood after the first major irruptions: all the adults were either immune or dead. A new crop of children would get hit by plague/smallpox roughly every ten to twenty years or so. This high evolutionary pressure meant that gradually Europeans acquired immunity to both diseases. That's why they could then successfully use biological warfare techniques to commit genocide on the American First Peoples by deliberately giving out blankets in which smallpox victims had died. They probably weren't going to catch it even if they hadn't had it because of genetic immunity.
Plague was different because nobody suspected fleas as a vector until the late 19th century. But Europeans are allegedly somewhat immune to plague too.
That is precisely what herd immunity means. We have a better way now - vaccine immunity - although relying on that alone will probably lead to higher death rates.