Sometimes cats bite when you are petting them - one reason for this is frustration from over exposure to an unattainable stimulus, like a bird at the window. They might also be seeing a stray cat outside, in heightened territory protection mode, and you reach out to pet them and are suddenly the recipient of redirected aggression. Signals you should be aware of include the cat's tail twitching and/or ears turning or flicking back and forth. Simulating the hunt through a Prey Play Sequence a couple times a day is a good way to relieve frustration in a cat. And if an outdoor stray cat continues to be a source of stress for your cat, you should consider visually blocking the window.