Mastodon, and Lemmy are different pieces of software, that communicate using a mutually-compatible protocol.
Sort of like how you can make phone calls with an Android and an iPhone, even though they are very different.
Lemmy.world is a Lemmy instance, like Mastodon.social is a Mastodon server. It is basically a server that runs the Lemmy software, and because Mastodon and Lemmy use ActivityPub, the mutually-compatible protocol, they can communicate.
In relation to lemmy.world specifically, Ruud
, one of the operators for lemmy.world, also runs mastodon.world(?), one of the major Mastodon servers.