Check if your program enter the ISP mode incorrectly. Just check if the PC(Program Counter) is pointing to a address like “0h1FFFxxxx”.
If that so, check the BOOT0 circuit and make sure it’s connect to GND via a resistance less than 4.7kΩ, such as 1.5kΩ.
:)