Anti-spam protection and Anti Malware Protection are provided by the same transport agent that can be enabled by default on edge transport or Exchange mailbox servers.
Microsoft 365 and Exchange online provide several features to help you and your end users easily collaborate in email. Each of these features has a different user experience and should be used based on what your users need to accomplish.
Configure your Exchange server to protect your Exchange Server mailbox databases in order to minimize the cost of deploying highly available and resilient messaging solutions while still providing a high level of service, data availability, and support for enormous mailboxes.