First of all, diagnostic fault codes never say to replace parts. They only indicate the circuit or system that needs further diagnosis. While it is certainly possible both parts are needed, it is not likely, but I don't have the information your mechanic used to make that call. Your car will have a minimum of two oxygen sensors. The rear one only reports on how efficiently the catalytic converter is doing its job. You don't have to replace that one for simply reporting what it sees. The front one tells the Engine Computer how the fuel / air mixture is being adjusted to be sure the computer has control over it. That sensor could cause the computer to command too much fuel which could overheat and damage the catalytic converter. Usually though extra air is sneaking in somewhere and that is what the oxygen sensor might be detecting. Here again, the cause of that "lean" reading must be diagnosed. You don't automatically replace the oxygen sensor for reporting the condition it is supposed to report.
A lot of problems detected by the Engine Computer can be intermittent. When the Check Engine light goes off while you're driving, that is a relatively minor problem. If the light only goes off after you've stopped and restarted the engine, that is a little more serious but it's still not a permanent failure. Those types of problems rarely fully correct themselves. Instead, it typically means the cause is in the beginning stages of its failure.
I'd want to know the exact fault code(s) that were recorded. The next thing would be to watch the two oxygen sensors how they switch between "rich" and "lean" on a scanner that displays live data.