In order to have full control over Android and iOS devices, it is necessary to format them. This step is mandatory as required by the manufacturers themselves, because enrolling a device without performing a factory reset places it in BYOD mode (Bring Your Own Device), rather than in fully managed mode.
Official Android documentation:
https://developers.google.com/android/management/provision-device
Official Apple documentation:
https://support.apple.com/pt-pt/guide/deployment-reference-ios/welcome/web