A person develops immunity to a disease through two main mechanisms: natural immunity and acquired immunity. Natural immunity is obtained when a person is exposed to a disease-causing agent and their immune system responds, producing antibodies to fight off the infection. Acquired immunity can be achieved through vaccination, where a weakened or inactivated form of the pathogen is introduced to stimulate an immune response. This prompts the body to produce antibodies and memory cells, providing long-lasting protection against future infections. Both types of immunity involve the immune system's ability to recognize and defend against specific pathogens, creating a defense mechanism to combat diseases.