Here is an example of what I mean.
I had a Buell that was running poorly and throwing a code. The code said bad O2 sensor, so the O2 sensor was replaced. The problem did not change, for better or worse. I dug into it deeper, employing some "actual troubleshooting" and found that the rear injector was sticking. The sticking injector was throwing so much fuel into the rear cylinder that the O2 sensor, which read only off the rear cylinder, was giving values pegged on the rich side. When the ECU leaned out the mixture and the O2 sensor reading did not change the ECU assumed that the O2 sensor was bad. It was not.
Trouble codes can tell you what is wrong, but they don't always tell you what you really need to do unless you apply some brain power.