Plants develop thorns as a defense mechanism to protect themselves from being eaten by herbivores or to deter animals from disturbing them. Thorns act as a physical barrier to prevent animals from feeding on the plant's leaves or branches, helping the plant to survive and reproduce in challenging environments.