Cats are attracted to catnip due to the chemical compound nepetalactone, which is found in the leaves and stems of the plant. When cats smell this compound, it triggers a response in their brains that causes them to become excited and playful. This reaction typically lasts for about 10 minutes before wearing off.