There was a Durham University study running from 2010 to 2013 where they asked the public to record their earworms (I contributed a few).
They suggest a few features that go into a particularly persistent earworm. A couple that stood out to me:
- Simple exposure. Songs that are currently popular tend to predominate. (There is a lot of Lady Gaga in their corpus.)
- A melody in the 'sweet spot' where it's generic enough to be easy to remember and sing but also has some kind of distinctive 'hook' like an unusual interval.
The popularity feature definitely fits Baby Shark. I think the melodic-sweet-spot feature does too: it's overall an extremely generic and repetitive tune, but also has the distinctive, painfully memorable 'doo doo do doo doo' bit.
The paper they published is here (pdf link). From a quick skim I'm not convinced that the stats are going to be all that great, but you'll have to read it more closely to judge for yourself. At the least it might give you some useful hints on other references and some terminology to google.
(And if you find anything interesting, let us know! I'm extremely prone to getting songs stuck in my head and would also like to know more about earworms.)