Spray can be a mix of anal gland material and/or urine, and it carries a very potent smell that other kitties clearly understand. We have become accustomed to calling it “inappropriate urination” when really the term “inconvenient urination” is more correct. The cat thinks it is absolutely appropriate but, for humans, it is really inconvenient.
As cats begin to roam around outside and mark that territory, indoor cats will want to leave a scent on their own territory which just happens to be inside our houses. The cats are doing what is normal and instinctual, and there go those humans getting all upset.
Deterrents to the “inconvenient” marking include using Feliway, a neutralizing pheromone spray or diffuser, or blocking the indoor kitty’s ability to see outdoor cats. In addition, it is a good idea to try to discourage outdoor cats from coming to your house or porch in the first place. (Try a motion sensor water hose/spray.)
If your cat has sprayed, we recommend using a neutralizing enzymatic cleaner to clean up after marking. Anti-Icky Poo is our favorite.