Programming STM32 Black Pill with ST-LINK/V2 dongle
A key driver of your problem is likely that the overwhelming majority of the compact little unofficial "ST-LINK" dongles do not actually drive their labeled reset pin, as the pin is connected to a different GPIO than wherever whatever firmware they are runnings thinks it is.  You can verify this while watching the pin with a storage scope triggered on it.  As they say, "you get what you pay for"

As a result, they won't work in a situation where you need to actually assert the target's actual reset line automatically.  Substitute an actual ST-LINK or use a Discovery or Nucleo board recent enough to be able to drive the reset (the early ones could not do that either)