The kneading motion with the forepaws is often done when the cat is in a pleased or expectant mood.
It probably imitates the kneading of a mammary gland by a nursing kitten, stimulating the release of milk from the mommy cat.
The behavior is also called milk-treading.
However, there are also scent glands on the feet of cats.
Scratching or kneading with front or back paws may also be involved in scent-marking, whether done on a favorite person or object.