We can unlock the records by enabling the apex code to set and remove the approval process lock.
Follow these step to unlock record:
1. Go to SetUp -> enter process automation settings in quick find box -> select the ‘process automation settings ‘ -> Click on the checkbox to ‘Enable record locking and unlocking in Apex’.