When were vehicles invented?

Depends on how you define vehicles. Various sources place the origins of wagons with wheels and an axle back to 3000 BC. The spoke-wheel horse drawn chariot dates back around 2000 BC. Hard to say exactly who to give the credit for the first vehicles.

Why were vehicles invented?

It sure beats walking, and using horses you can move a lot faster than walking.

If you define vehicles as something moving not powered by an animal, the creation of steam powered locomotives started in the late 1700s. The first full-scale working railway steam locomotive was the Coalbrookdale Locomotive in 1802. Coalbrookdale is a village in the Ironbridge Gorge in Shropshire, England.

https://www.locos-in-profile.co.uk/Early_Locomotives/Early_1.html