Deductions & credits

I am sorry, but I do not understand. I only ever took the std mileage rate. So why is there depreciation? I bought the car for 6500, sold it for 6000. That is a $500 loss? I put approx 30K miles on it over the 2 years.  Why do I pay tax on $6000 gain???   - I put my mileage in for this year, but then when I put the car sale in, the mileage goes away. is that part of the glitch?