I would suggest not to focus on teaching your child to fear a car. If, from such a young age, he learns cars are outright scary and dangerous, it might cause a distressing relationship toward large motorized machines. And while that in itself isn't necessarily bad, it is when it turns into, perhaps, a phobia to either driving, or even only looking at a large machine in general that it can be a problem. Not that every child will become negatively affected if they were taught to fear a car, but whether it is isn't learned until a problem is already developed, so I am hoping to flag this side of the coin so readers might understand a difference between the easier act of placing a fear, or teaching a lesson.
Teaching a child is a process. He will not know what you know in one day. Perhaps not even in a month. Some take longer. There are major steps to developing an understanding in your child about pedestrian safety, and will take a while.
It does sound like your child is an explorer, or simply fascinated by these car constructs, and simple instructions to stop doing the thing he decided to do will not work simply because he doesn't understand why. You might tell him they can hurt, or they are dangerous, or even that the driver cannot see him, but for such a young explorer, those concepts do not hold meaning. Yet. Your job is to give them meaning and reason.
Until he learns, do not let him wander off. He isn't the boss, you are. Hold onto his hand, and do not let go. Does he yell/scream? Does he pout? Do not give in. (But, a child who throws a tantrum is a separate problem, and a process all its own.) And if he asks "why", avoid answering with just a "because I said so", because to a child that is the same as no reason. That isn't to say that you shouldn't let him know you are the boss, but when a child asks a question for it be be unanswered (in his mind) is discouraging and/or annoying to a child, and it is a wedge in his understanding about what just happened. Answer his why with a very basic reason, and an explanation. Even a "because I said so" is fine with a thought-out but simple explanation that he can digest. The point is, give him something to process instead of "nothing".
If he does not ask why, distract his trying to pull away with asking him why: "Why are you trying to get away?" or "Why do you like it so much?" or "Why aren't you listening to me?", etc. Don't be angry and don't yell. Ask him genuinely. Interact with him. It might get him to think about his actions. It is likely that he'll answer simply "I like it!" Ask why. Try to understand his thoughts, or try to get him to develop his thoughts about his actions. Once in a while (or even every time, if you're inclined), ask again. The purpose of this is simply to get him to think, and it is only when thinking starts, can understanding start.
And it is when understanding can start that you can eventually explain to him why he needs to be careful. "They can give big boo-boos/owies." or "other people sit in these to move them, and they can't see through the walls, so can't see you." , etc. A child still won't really fully understand, but it gives them things to think about while you're still holding tight, and it prevents instilling fear.
But for the tiny explorer that manages to escape, scold him instead for not listening to you, and not because he's in danger - until he understands what danger is. Perhaps also ask him why he didn't listen to promote that thinking of his. Work with him in understanding the situation.
I hope I helped.