Trying to enroll a device, but during the installation of the enrollment profile getting the error message - The profile (com.xxxxxx.mdm:c1c8048f-1450-447 3-8bba-1c714c4ce492) could not be installed due to an unexpected error. <CPProfileManager:-65002>"
Device enrollment failing with error CPProfileManager:-65002
-65002
indicates a CoreData database error. There's no mechanism fro the databases to recreate themselves other than to wipe them, so there's a series of things you can try to correct the problem.
First, just restarting the device may resolve the issue. It may also help to update macOS to a newer version. Reinstalling the OS might help as well.
If those fail, you may need to manually wipe the databases. You can disable SIP, delete the /var/db/ConfigurationProfiles/ folder, and restart. This isn't recommended though as it may leave some things partially configured. For instance, if a VPN was set up using a configuration profile, deleting the databases would leave the VPN network configured, but you wouldn't be able to remove or update it normally. You may be able to reconfigure it by reinstalling the same VPN, but you're into unknown territory here and may be introducing further issues.