Unlike interactive dogs, cats, in general, are distant and cold. So, when your cat rubs against your leg or jumps on your lap, it is not necessarily being affectionate to you. It’s more likely a way of telling you that things are out of sorts.
Your cat might cuddle next to you to get warmth. It might rub up against you when it’s hungry or thirsty. Or it might start kneading you with its paws when it is emotionally or physically distressing. Or it might be trying to be playful as a way to get physical stimulus.
Cats really have their own quirky communication. Understanding them is part of providing them with the best care.