My son did this, along with putting his fingers in his ears and doing it repetitively. We think he may just be experimenting with how it sounds when his ears are plugged and unplugged quickly. They also ruled out ear infections and anything else that might cause pain or discomfort. He stopped not too long ago and every now and then he’ll do it if there’s a lot of noise going on and he seems to just like the way it sounds.
My son used to do the same thing, as well as putting his fingers in his ears and sometimes picking and even making himself get scabs on the inside of his ears (not deep in the canal, but like the inside of the outer ear, if that makes sense…). His doctor said ears are perfect, no wax build up and never had any ear infections. She suggested it could be dryness in his ears, especially as the seasons change and it’s getting colder and dryer outside…he seems to be doing it less and less these days…just figured I’d mention the dryness thing too Incase it was another possible, yet innocuous, thing for your LO too!
My toddler has been "hiding" by covering his face and holding one ear to be goofy. Also, he covers his ears when we are talking normally at random times. Seems to be experimenting with it. I would watch for signs of pain liked not eating, crying, not sleeping well.