As with many microbes, becoming infected produces natural antibodies. That doesn't mean you can't become reinfected. It means subsequent infections will either remain subclinical (produce no symptons), or have milder symptoms, and hopefully will be of shorter duration.
What is pretty clear, at least to me, is that becoming infected produces antibodies to many more proteins of the covid virus than the vaccines do. This should provide better protection from subsequent infections since, as the virus mutates, you have better odds that you will have antibodies that match up with some parts of the virus.