Often cats will bite when being pet as a way of expressing that they no longer wish to be pet. Some cats only like to be pet in small amounts at a time before they decide they've had enough and will let the person petting them know by biting them softly or scratching. Other cats will become severely agitated with repetitive scratching and bite hard enough to cause injuries.
Many cats show signs that they are unhappy with the petting before they lash out and bite. Signs of agitation from an unhappy cat include ears flattening up, tensing their body, twitching their tail and becoming fidgety. Excessively petting a cat may cause them to feel excitement, arousal, static electricity and sometimes even pain.
Since all cats have different personalities and traits, some enjoy being pet more than other do. While one cat may enjoy petting for about five seconds, another cat might enjoy petting for a much longer period. It is possible to teach a cat to tolerate being pet by offering them their favorite treats after a very brief amount of petting.
Cats that get plenty of social time as kittens have a tendency to enjoy being pet more than cats with less social time during their kitten days. Enjoying being pet is also part of the cat's genetic makeup, so a cat cannot control becoming agitated with repetitive petting.