There are a lot of reasons your cat might “go” outside his box: He’s sick, his litter is dirty or not in a place that suits him, or you don’t have enough boxes. Or he may be stressed about something or hurting. If your cat is older, things like bladder stones, urinary tract infections, kidney failure, diabetes, cystitis, or pain from arthritis or trauma may cause him to go potty someplace he isn’t supposed to.
Always talk to your vet about litter box issues. And never punish your cat for going outside the box. You don’t want him to link punishment to his litter box.