Cats can get very set in their ways and changes to their environment can be very stressful to them. Things like a new dog, a new baby, sudden loud noises, or a move to a new location, can upset them greatly and they can start marking as a way to comfort themselves that they do have a territory. If at all possible prevention is best. When you bring a cat to a new home try using the FeliWay plug in diffusers to ease the transition. I am also a big fan of getting a cat used to a kennel or cage, someplace it feels safe to go to when changes in the environment are a problem. This should be set up with a comfy bed and maybe food and it can be a place you can lock them when fireworks or festivities are going on outside your door, when guests are over and you don't want them running out, where they can go to be away from a new dog or baby, or when introducing them to a new location. Comfort is key here and if your cat is relaxed he or she will be much less likely to spray.
These cats are urine marking, and urine marking isn't a litter box ..
Cats sometimes stop using their litter boxes when they feel stressed. Identify and, if possible, eliminate any sources of stress or frustration in your cat’s environment. For instance, keep her food bowls full and in the same place, keep her routine as predictable as possible, prevent the dog from chasing her, close blinds on windows and doors so she isn’t upset by cats outside. If you can’t eliminate sources of stress, try to reduce them. Incorporate the use of sprays or diffusers that deliver a synthetic pheromone that has been shown to have some effect in relieving stress in cats.
It's getting to be a big problem
If you want to prevent cats from eating your garbage or plants, digging in your yard and stretching at trees, spray liquid repellents – sprays – onto outdoor surfaces, such as:
Stop your cat's spraying!!! This really works!! - YouTube