When a cat starts to immediately scratch or bite the second you pet it, it usually means the cat is overstimulated and/or has a lot of energy. The biting and scratching we are referring to is more like rough play, not a sign of attack.
If the cat is in a shelter and confined to small space or in a home setting and sleeps a lot, the biting and scratching normally means the cat is lacking exercise and stimulation release and will need some encouragement to initiate the exercise. Use a toy like a feather or wand with dangling item to play with the cat so it runs around and releases that energy. Once the cat shows signs that he/she is getting tired and starts to relax, then you may attempt to pet it. If the cat still shows signs of hissing or negative behavior, set the toy down, then walk away. If the cat starts napping a few minutes later, try again. Once the cat allows the petting without biting or scratching, reward the cat with praise in soft pleasant voice. A treat is an excellent idea to reward good behavior. It is recommended to exercise and play with the cat at least twice a day for several minutes especially for young adults to learn good habits early. Repetition and consistency are key to any training. Good luck!
If you have a success story, please share with us and we'll post it here for others to learn. Email us at email@example.com