Back in WW2 (and today) many aircraft throttles were a knob on a little rod that you would pull away from the instrument panel for idle, and push it forward up against the panel for full throttle.
The knob was the ball and the wall is the instrument panel. (firewall)
So to say "balls to the wall" it means to fly your plane at full throttle.
But it's evolved to simply mean operate your vehicle at full throttle.