You should review the different deployment models for Classroom in the Classroom User Guide.
There are three mutually exclusive options:
MDM-synced classes
Unmanaged nearby classes
Classes synced with Apple School Manager
The education payload only applies to "MDM-synced classes." Support for remote students is only supported for "classes synced with Apple School Manager." In addition, installing an education profile overrides "classes synced with Apple School Manager" and doesn't rely on Managed Apple IDs (the configuration is entirely managed by MDM).