You can unlock your Android phone even if you've forgotten the passcode, but you'll usually need to factory reset the phone.
You can reset an iPhone, even without the password, by putting it into "recovery mode" or erasing it via iCloud's Find My ...