Catnip, technically called Nepeta, is a genus of about 250 plants. It is related to mint. Nepeta is known better as catnip because of the effect it has on cats.

While the effects can vary, catnip is said to affect about 2/3 of all cats. Some cats get aggressive, some get mellow, and other get goofy. One of my cats is not affected at all. The other gets goofy.

The effect is hereditary. As an interesting aside, most Australian cats are not affected, as the effectiveness has been (unintentionally) bred out of the cats there.

In the cats that are affected, the cause is the smell. It interacts with their brains to cause a euphoric sensation. After a few minutes, the smell wears off (almost like a temporary tolerance is built up) and the cat goes back to normal. After a few hours the tolerance is gone and the fun can begin again.

Source: here and here.