Cats' brains process and respond to catnip by releasing a chemical called nepetalactone, which is found in the catnip plant. This chemical binds to receptors in the cat's brain, causing them to experience a sense of euphoria and increased activity. The evolutionary purpose behind this behavior is believed to be related to cats' natural instinct to hunt and explore, as the effects of catnip can cause cats to become more active and playful.