Just wanted to add my $0.02 as I have purchased new, used, and rentals on many occasions.
If you know the vehicle you want (not the make, but the actual model) and you are willing to do the legwork you should be able to do better new than CarMax, but using their price as a good starting point for haggling can be helpful.
If you don't want to take the time (even for a few thousand dollars, some people just will not haggle or shop around), CarMax is fair.
Also, for used cars, if you aren't mechanically inclined or live with/near someone who is, don't buy a used car from a person or small dealership. I always tell people who asked to purchase used from a large dealership that has an established warranty. If for no other reason than that you can take them to court if they screw you over. Yes, they are a bit more expensive, but detailed research and analysis has been done (easy to google) that shows cars bought from private owners who sell privately have more issues.
As for rental cars, it's easy. Don't buy a used "compact" or "sub compact" from a rental facility. If you stay away from their cheapest models you will get a vehicle that was likely only rented by families or companies. And the only "company" that I think is a bad renter is the military as they overwhelmingly employ young testoterone filled men who are practically encouraged to treat equipment roughly. And the military almost always rents the cheapest possible car.