Ensure that both the ST-Link firmware and STM32CubeProgrammer are updated to the latest versions.
Check the power supply to the board and check the jumper settings.
Try select the "Connect Under Reset" mode in STM32CubeProgrammer and erase the whole MCU.
Hope these steps and tips help you resolve your issue.
In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
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.