The short answer
Cat urine smell lingers because uric acid crystals don't wash out with soap. The fix is to find every spot (a UV flashlight makes old stains glow), soak it with an enzyme cleaner and let it dry, and avoid ammonia cleaners, which smell like urine to cats.
Find it
A 365 nm UV light like LumenShooter S3 or Simple Solution shows dried urine in a dark room.
Clean it
- Soak the spot, including padding beneath carpet, with an enzyme cleaner such as Rocco & Roxie or Nature’s Miracle Oxy.
- Leave it to work and air dry; don't rinse it straight away.
- Repeat for old stains.
Stop it happening again
- Scoop daily and add a box if you have several cats.
- Clean boxes with mild soap, not strong scents.
- Pheromone diffusers can help stress marking.
SafetySudden peeing outside the box can be a urinary problem; see your vet.
Products mentioned

Enzyme cleaner · Rocco & Roxie
Rocco & Roxie Enzyme Stain and Odor Eliminator 32 oz
Enzymes, color safe.

UV urine detector · LUMENSHOOTER
LUMENSHOOTER S3 365nm UV Flashlight
365nm, three LEDs.

Enzyme cleaner · Nature's Miracle
Nature's Miracle Oxy Set-In Stain Destroyer Cat P-98173
Oxy formula, 1 gallon.
Questions readers ask
Why won't cat urine smell go away?
Uric acid crystals stay behind; only enzyme cleaners break them down.
Can I use bleach on cat urine?
Don't mix bleach with urine; ammonia and chlorine can form harmful fumes.