They can also be effected by water damage, or being bumped in a minor collision like a parking lot bump, or freezing, especially if there's moisture behind them. It could also be a damaged wiring harness. There are many reasons they'll throw an error code. And since you bought the car used you don't really know what the car's been through.
With all the wild weather we've been having across the nation, I see all these people on the news driving through flooded streets and I can't help but think about the havoc that's going to cause with all the electronics in these modern cars. Not necessarily immediately, but for sure down the road when things start to corrode.