While you may find people using the terms interchangeably, Office 365 and Microsoft 365 are two distinct plans offered by Microsoft. Office 365 includes Microsoft Exchange and SharePoint for businesses which have their own network., and an active directory service to authenticate the users with access to the network. This is in addition to the standard MS Office programs, Excel, Word, PowerPoint, and Access.
Microsoft 365 expanded on Office 365, and is meant to replace it. While it also has Word, Excel, PowerPoint, and Access, It is tailored for offices that rely on the cloud, and don't have their own network. Azure Active Directory comes with Microsoft 365. It is a cloud-based system for authenticating users, but you cannot set it up with a server. Azure Active Directory works with Microsoft Intune in M365 to restrict access to data. Microsoft 365 also includes Enterprise Mobility and Security which facilitates the control of devices which are in different locations.