My 9mo always claps when he is crying/sobbing

He’s done this since he learned how to clap - at first I thought it was something he was doing to cheer himself up because I always smile when I’m clapping and say “yay” so he thinks it’s something we do when we’re happy?? Whenever he is REALLY crying or upset he just starts clapping and it kind of breaks my heart. Any ideas why he might be doing this?