The dog presumably got inside the car through the open window. It was totally skin and bones, sad, hungry, and extremely exhausted.