Failure to use the litter box is the number one reason adult cats are surrendered at shelters and rescues.
Even though sometimes it might seem like your cat is urinating outside the box just to spite you, i.e. when you go out of town for the weekend, most of the time there’s a medical cause. If it hurts to use the litter box, the cat will avoid it.
Somehow the cat-owning public got the idea -probably from their veterinarians- that urinating outside the litter box always means the cat has a urinary tract infection (UTI). It turns out that UTI’s are actually pretty uncommon in cats under the age of 8, and most young cats that urinate outside the box have a condition called Feline Lower Urinary Tract Disease (abbreviated FLUTD).
Cats with FLUTD have all the signs of UTI’s except one - no infection. These cats experience pain, bloody urine, and frequency of urination, but there’s no bacteria in the urine. Most experts believe that stress plays a factor, and also lack of enrichment for indoor cats.