I don't think you need to understand anything about php or Python to understand this. I think the email comparison is the best metaphor.
Gmail and Yahoo and whatnot all speak the same language, "email". They've friended one another ("federated") and have unfriended spam mail servers. They've also settled on roughly the same design for their mail clients, but they didn't need to.
Unlike Gmail, there are a zillion Mastodon servers, because anyone can make it. And unlike email, the "ActivityPub" protocol can be used for a bunch of different uses. Mastodon cuts it up to look like Twitter, Pixelfed cuts it up to look like Instagram, PeerTube cuts it up to look like YouTube, etc.
Basically, Gmail is just one email server, and it speaks SMTP .
Similarly, Mastodon.social is just one Mastodon server, and it speaks ActivityPub.
In practice, I don't think you really need to understand it any further than the email analogy. I just tell those interested to sing up for Mastodon.social and see if they like it.