The Autobots came to earth in the 1980’s but already had knowledge of the planet so I think they had previously sent a scout for reconnaissance. This scout was Herbie. However, he later decided to be a conscientious objector in the war between Autobots and Decepticons and spent his life as a racecar driver. There was a scene in the Lindsay Lohan movie where the bad guy turned away and Herbie made fun of him by making a funny face, but doing this required him to sort of expand/disassemble his parts much like Autobots are capable of.
It always bugged the shit out of me that there was no explanation for some random car being sentient so I’m gonna just go with this.