CarMax gives you a free history report on the life of the vehicle to date, including how many owners it's had, any accidents it's been involved in, any recalls it's been included in, registered odometer readings over the life of the car, and so forth. (Details here:
https://www.carmax.com/articles/free-vehicle-history-report-...)
If you don't trust CarMax to give you an accurate report, you can buy a separate one from a third party like Carfax (https://www.carfax.com/vehicle-history-reports/) to confirm the details.
> CarMax has no incentive to fail a car at inspection. They'd rather sell it to you and if it breaks, fix it under warranty.
Any car you buy from CarMax can optionally be covered by their "MaxCare" extended warranty, which lets you choose a deductible and then obligates CarMax to pay the remaining cost of any repairs to the vehicle beyond that deductible. So if you set the deductible at, say, $250, and then you get the vehicle home and discover that the transmission is shot, the worst case scenario is you're out $250. CarMax eats the rest of the cost.
Car YouTuber Doug DeMuro bought a Range Rover from CarMax with this type of coverage a few years back. He paid $3,899 for the extended warranty, and CarMax ended up paying out $16,925 on warranty repairs over the six years he owned the car. More details here: https://www.youtube.com/watch?v=E3jA55TJboA