There's a legitimate reason why a car immediately loses its value. People are more likely to sell cars that have something wrong with them. The market price for a car that you just drove off the lot is not the market price for an average car of that age, it's the market price for the subset of cars of that age that people want to sell. Because a car in that subset is more likely to have something wrong with it, its value is lower. Even if you personally are not selling the car because there's something wrong with it, it's hard for the buyer to know this.
If people had magic X-ray eyes that could tell that the car you just drove off the lot doesn't have more problems than an average new car, then its sale price would be similar to a new car. But they don't.