Spraying or litter-box avoidance?
The first step is knowing what you are looking at, because the two problems have different solutions. A spraying cat stands upright, backs up to a vertical surface such as a wall, door frame or sofa side, quivers its tail and releases a small amount of urine at nose height, it is scent communication, not a toilet mistake. Litter-box avoidance looks different: larger puddles on horizontal surfaces like floors, rugs or beds, often with the cat squatting as usual. Watch where and how the urine appears, and if you can, observe the posture. Both males and females can spray, including neutered cats, though intact cats do it far more.
Rule out medical causes first
Before you change anything at home, book a veterinary check. Urinary tract disease, bladder inflammation, crystals and kidney problems can all make a cat urinate in new places or strain in ways that look like marking, and some of these conditions are painful or even dangerous if they are missed. This matters most if the behavior started suddenly, if the cat visits the litter box often, cries while urinating or produces only drops. Your vet can test a urine sample and examine the bladder. Only when medical causes are ruled out does it make sense to treat the problem as behavioral, and never give a cat any human medication.
Common triggers
Spraying is almost always about stress or territory, the cat is trying to make its world feel safer by labeling it. Common triggers include a new cat in the home, neighborhood cats appearing outside windows or spraying near your door, moving house, renovations, new furniture, a new partner or baby, or changed routines. In multi-cat homes, competition over resources is a classic cause: too few litter boxes, food bowls or resting places forces cats to guard and mark. Try to play detective, note where the marks appear, window walls point to outdoor cats, hallways and doorways to tension inside the home, and the pattern will guide your fix.
What actually helps
Neutering is the most effective single measure for intact cats and greatly reduces marking. Clean every marked spot with an enzyme cleaner so the scent is truly gone, never use ammonia-based products, they smell like urine to a cat and invite refills. Reduce the triggers you found: block the view of outdoor cats with window film, add litter boxes (one per cat plus one), spread out food, water and resting places, and keep routines predictable. Pheromone diffusers can ease stress in many homes. Above all, never punish, scolding or water spraying adds stress, and stress is the fuel marking runs on, so punishment always makes it worse.