If you dont need the data two options 1. Install GrapheneOS on it. It's absolutely a more secure option. 2. Reflash it using stock android at flash.android.com
Flashing must be enabled in the OS settings. Without that, the bootloader can't be unlocked.
Yes sorry forgot that. First thing to do when buying a phone is to enable Developer settings and unlock bootloader I guess