Factory resets are a common way to fix many problems on smartphones, but they aren't perfect. One thing that a factory reset won't do is remove any sort of mobile device management (MDM) software from your phone.
MDM software is designed to allow businesses or schools to manage and monitor employee or student smartphones remotely. This can include features like restricting certain apps or websites, remotely wiping the device if it's lost or stolen, and more. Because MDM software is usually installed by someone other than the phone's owner, it can be difficult to remove.
A factory reset will usually get rid of any other kinds of software that have been installed on the phone, but MDM software is designed to be persistent even after a reset. If you're trying to get rid of an MDM program, you'll need to contact whoever installed it in the first place and ask them to remove it. In some cases, you may be able to uninstall the MDM program like any other app; in others, you may need special permission from the administrator.