Table of Contents
When you shift the gear selector from “Drive” to “Park” and the vehicle is still moving, you engage the parking pawl, which stops the movement of your transmission. This causes an abrupt stop of the vehicle and can severely damage the transmission and its affiliated parts. That's why you should never shift from D to P while driving. Only shift from D to P when the vehicle is fully stopped.

If your vehicle has a mechanical link between the shifter and transmission, you can shift from Drive to Park when the vehicle is still moving, but doing so can damage the automatic transmission.
Mechanical Shifter

Older vehicles, like the one shown in this picture, have a mechanical link between the gear selector and transmission. While it is possible to shift from D to P while driving, you should not do so if the vehicle is still moving.
Shifting from D to P when driving can cause damage to the transmission.

In an automatic transmission, there is a ring with teeth on the output shaft of the transmission. When the transmission is shifted into the park position, the parking pawl lever is lowered against this ring.
If the vehicle is still moving, the lever will not engage into the ring, causing a grinding noise until the vehicle comes to a complete stop.
Drive-by-wire / Electronic Shifter

On vehicles with an automatic transmission with a mechanical link between the gear selector and the transmission, you can shift from D or R to P when driving, but doing so can cause damage.
Shifting from D to P when the vehicle is still moving can cause loud noise coming from the transmission and may even cause damage to the transmission.
The faster you are driving, the higher the likely hood of causing damage to the transmission when shifting from D to P.
Newer vehicles with automatic transmission use what is known as drive-by-wire technology and won't allow you to shift from D to P while driving.