Active Directory, also known as AD, is Microsoft's directory service. AD essentially acts as a list of people who have access to a network. Each organization usually has its own AD system, either installed locally (known as Active Directory Domain Services or ADDS) or through Microsoft's Azure cloud (known as Azure Active Directory or AAD).
AD is the system used in the background to confirm you are who you say you are when you log into a system with your credentials. It keeps a global list of users who have access to various systems within a Microsoft environment, usually including Windows, Office 365 services, SharePoint on-prem, Skype, OneDrive, and others.
When you're prompted to log in to any Microsoft-based system that's connected to your organization, your identity is being confirmed through AD. Some organizations are large enough to warrant multiple ADs. Some have multiple ADs because they were set up independently in the past and only connected later on for organizational reasons.
Because different organizations have different AD systems installed, you cannot generally use your creds from one AD system and log into a system that uses a different AD. That said, IT can federate multiple AD systems to recognize each other. Two organizations that federate provide their respective AD systems access to the other. This makes accessing systems across the organizations easier if they happen to work together frequently. Federation is a way to provide single sign-on (SSO).
It's thanks to federation that, for example, you may be able to use your
name@companyA.com email address to log into a SharePoint system at Company B (e.g.,
https://sharepoint.companyB.com/) or into Company B's Office 365 tenant without an
@companyB.com email address.