If you encounter an error when enrolling a device, there are a few possible causes:
There might be a network issue. Try to enroll the device again using a mobile Internet hotspot as the Wi-Fi connection to exclude any network issues.
There may be a restriction in place to deny enrollments from a specific location.
There may already be an MDM profile on the device.
If you still have problems enrolling the device after checking these possible causes, it may be necessary to wipe the device (when using Apple Configurator or automated device enrollment) and restart the device enrollment process.