Both services use the ActivityPub protocol, so to put it very simply the data format used by both services is the same, they just render it differently on your screen. Then they are pushing/pulling the data for posts and comments from other instances as users request it, e.g. by viewing this lemmy instance through Mastodon.
It’s gotta be Penumbra: The Black Plague and Amnesia: The Dark Descent back when I played them 12 years ago. Not many games have created the same amount of tension for me while playing.