We have 2 cats and 1 is 17 years old. Recently he began only pooping on the carpet near the pan, but always peeing in the pan.
Long story short, the vet found arthritis in his last vertebra and treated him with a cortisone shot. This seems to have helped a lot, but occasionally he does a repeat performance.