When the car accelerates, it accelerates any object bound to it at the same time*: everything in it gains kinetic energy and everything travels at the same speed. When you remove the constraints (by throwing a ball), it still has the speed it has gained from the car acceleration because of inertia. Only exterior forces change the velocity of a solid. So if you throw it in the car while it's going straight at a constant speed, from the car referential the behaviour (trajectory) of the ball will be the same as if you were standing still on the ground. If you had thrown it out the window though, the friction from the air would have slowed it down and it would have appeared as though it was moving backwards whereas it would have been moving slowlier than you (and decelerating).
One of the first examples that come to my mind is in action movies when the hero is throwing himself out a car to avoid being smashed against a wall at great speed: he doesn't just get out and walk, but injures himself rolling in the direction the car was heading. He's in fact (trying to) losing(/lose) kinetic energy (hence speed) through friction with the ground, because he had acquired that kinetic energy from being in the car (otherwise the car would move but not him with it, meaning he was a ghost - plot twist).
Another way to think about it: you're already travelling at more than 3km/s in a Earth centred inertial reference frame (axes pointing at fixed stars), and yet you're still falling vertically when you're jumping. That's because you've already acquired that kinetic energy, and you're still travelling at the same speed even in the air because the Earth is not changing its rotation speed.
*: What happens is, the car starts moving but everything in it is at rest - as it moves it eventually makes contact with people and objects if they weren't against a backrest, and starts applying a force to continue going forward, which will accelerate them (if they're too heavy, that force will have to be high and the car will accelerate slowlier).