If you bought a device legitimately from a previous owner, they must remove the device from their MDM portal before selling it. If they didn’t, the device is technically stolen property in the eyes of Apple/Microsoft/Google.