Concur w/Nevada, the brake light switch isn’t related to the other repairs. In fact I suspect you already had that problem when you drove it to the shop, but didn’t realize it. The shop – by spotting it – may have saved you from an expensive “no stop lights” traffic citation.
An O2 sensor can be damaged if fluids are spilled on it or if it is accidentally hit with something or levered. So it’s possible the O2 sensor was damaged during the repair, but unfortunately it’s not possible to say that with any certainty. O2 sensor codes are asked about here all the time, that’s a very common code area, and I don’t think I’ve ever heard a claim that the O2 code was caused by a damaged sensor due to a repair.
It is unusual for an O2 sensor to fail at 40K. Many last the life of the car. I changed mine out proactively at around 200K on my Corolla. I expect it was actually still working fine. So an O2 sensor failure is a little unusual at 40K. But still, such a failure is far from impossible.
One thing you might check, certain emissions equipment has longer warranty periods than the main warranty that comes with a new car. The O2 sensor is part of the emissions system so you might ask if that extended emissions warranty applies. I think if it did, they would have given you the warranty discount to you already. It’s probably in their computer system. But no harm to ask.
Don’t know about what the 4-wheel dash warning light is for on a RAV 4. What does the owner’s manual say? It’s possible the service may have confused one of the computers. But the light is now off, right? So whatever it was, it’s working now.
Were the maintenance and repairs necessary? Belt replacment and scheduled cooling system service and fluid replacement for the 4WD system are definitely necessary. 4WD vehicles are almost always more expensive to maintain and repair than 2WD vehicles. I know this for a fact, b/c I have both kinds. The 4WD vehicle I own requires considerably more $$ per mile driven in repairs and maintenance than the 2WD. And as fair warning to you, this gets worse the older the 4WD vehicle gets. Brake light switches are a common failure item. I replaced the one on my truck a couple years ago. And that wasn’t the first time I had to replace it. I’ve already covered the O2 sensor situation above.
Toyota unreliable? All cars are inherently unreliable simply b/c they contain so many moving parts. Toyota’s are thought by most car owners who’ve owned them to be as reliable or more reliable than most other makes. Newer cars – because buyers demand so many cool features and modern conveniences, new federal safety, emissions, and mpg requirements – newer cars in general seem to be less reliable than cars of the 1990’s era, adjusting for mileage and age of course.
If reliability is a concern to you, next time you purchase a car check to see what Consumer’s Reports says about that make and model. Beyond that, only buy features that are a necessity to you. Air conditioning systems, automatic transmissions, non-factory sound systems, security systems, automatic window and door locks, 4WD/all-wheel drive, tire pressure monitoring systems, and key-less lock systems w/fobs are all common failure items reported here. Best to avoid those unless you need them.