One many newer cars there’s two O2 sensors (or more). One (or more) is before the catalytic converter many times on the exhaust manifold. This one is mostly used to control the fuel/air mixture. The O2 sensor after the cat is used to tell if the cat is working correctly.
The first rule of using an OBDII code reader: The codes are good place to start the troubleshooting, but you should never, ever change a big ticket item based just on a code. There’s one vehicle I’m familiar with that often throws a knock sensor code. Changing the knock sensor is about a $700 job. And it seldom fixes the problem as the knock sensor code means the engine is knocking or pinging.
Before changing the cat or any O2 sensors, I’d check the wiring to the sensors. They are in a high vibration and heat area and often break at the connectors. Splicing back together a broke wire is a cheap fix.
Next with the engine warmed up from a lot of driving, I’d use an infrared thermometer over the cat to see if you can find any relatively cold spots. That’s a good sign that the cat might be bad.
Next you want to resistance check the O2 sensor. If it passes the sensor is probably good. Some 02 sensors have a heating circuit to get them working faster when the engine is cold. That circuit could be bad and not have anything to do with O2 sensor itself.
How many miles are there on the car? It’s possible that the cat(s) are seeing better days. But before I’d write them off, I’d use some very good fuel injection cleaner like Techron for a tank or two. I’d also go out and do an “Italian Tuneup” by warming up the car and flooring it from a slow speed up to the speed limit a few times. Something like the on ramp of an Interstate up to the speed limit.