Lemmy and lots of other software use a fediverse extension called 1b12 to keep everything in sync.
In a nutshell it means Lemmy communities can follow other communities, and they keep each other in sync. The same applies for other types of communities, like PieFed communities, Mbin magazines, NodeBB categories, etc.
Mastodon doesn't have a concept of community or categories, so they don't support this kind of synchronization.