So how does the body "Remember" what diseases it can fight?

I asked this question myself, in the year 4 BC: