Some of it is called "superstitious behavior." Animals do it too, just like we do.

They know these tricks have caused good things to happen to them in the past, so they figure, why not try them now?
Thor will always try to squeeze a handshake into a command he's not sure about. Like if I put him in a Down, he paws my hand first, just to cover all his bases.
You can try to extinguish this behavior by ONLY rewarding when you have requested the behavior. Then they know the rule is, it won't work unless it was asked for.