You need to answer a few questions,
1- How old your car is? Means how much Kms it has done
2- Transmission oil replaced on time if it was due, yes then check the transmission oil level.
3- If the Kms are low, oil is replaced on time and level is OK, mean all is OK then i suggest you need to change your parking habits. Do not put your gear on P untill and unless you car is not fully stopped or not in motion. Usually it happen when the person comes out of the car i hurry and becomes his habit.
4- The other reason could be the transmission parking Pawl, it might be worn out or damaged. But this could be the least possible reason.
Rest a little sound is always there when you put P in R or D.