I don't know the STM32 behaviour if you read a locked chip - does the read just fail? Or does the read proceed, but give rubbish data?
Also, perhaps the owner of the code has done something "clever" to prevent copying; eg, keying to the unique ID?
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
As it could be something related to the option bytes (different values). You can check and compare the content of the option bytes using STM32CubeProgrammer tool going to OB menu:
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.