Mastodon is a social networking service. It makes use of a protocol called ActivityPub that allows a network of servers (also known as instances) to communicate with each other. This is called decentralization. Servers can choose which other servers they communicate with through a process called federation. This whole system is called the Fediverse.
ActivityPub doesn't only have to be used with Mastodon, though. It allows lots of different types of services to communicate in different ways. For example, Pixelfed is another social media app that is build with the ActivityPub protocol that is for photo sharing. Because it uses the same protocol as Mastodon, you can view content from either service in both (but we're getting ahead of ourselves...).