Why does a cat like being stroked?

 

Because it looks upon humans as 'mother cats'. Kittens are repeatedly licked by their mothers during their earliest days and the action of human stroking has much the same feel on the fur as feline licking. To the kitten, the mother cat is 'the one who feeds, cleans and protects'.
Because humans continue to do this for their pets long after their kitten days are behind them, the domesticated animals never fully grow up. They may become full-sized and sexually mature, but in their minds they remain kittens in relation to their human owners.
For this reason cats – even elderly cats – keep on begging for maternal attention from their owners, pushing up to them and gazing at them longingly, waiting for the pseudo-maternal hand to start acting like a giant tongue again, ming and tugging at their fur. One very characteristic body action they perform when they are being stroked, as they greet their 'mothers', is the stiff erection of their tails. This is typical of young kittens receiving attention from their real mothers and it is an invitation to her to examine their anal regions.