All snakes rattle their tails. It's just that rattlesnakes are the only ones that have the rattles on the end.
But if you ever come upon a king snake or rat snake in a pile of leaves or gravel you'd swear you heard a rattle snake.
Generally snakes rattle their tails as a warning. It means "Leave me alone."
The babies do this because they are scared and see us (people) as a threat or possible predator. Once they get older and get to know you, they usually outgrow the tail rattling.
My Corn snake rattled its tail the very first time I tried to pick it up. It has not done it since.