from my point of view that is correct and normal behavior and it have nothing with any code in your board.
On Board ST-Link is powered via its USB cable. So how you connect it to a PC, then you will ST-link VCP device in System device manager is shown and then you can connect to it. Now you can reset the board or On/Off external power source (that will reset only the MCU not the ST-link) but ST-Link is still powered by the host side, that mean the connection is still established.
However, your third case is different, because when you unplug USB cable of ST-link, then it is not powered and established connection with PC was lost, the VCP was closed on the host side. When you plug it again, then the connection must be established again (you must VCP open again).
I am not sure what you are asking for.
That is also correct, when you first time conect a device to your PC, the system will store identification (VID/PID) from USB interface chip and assigns a free number of COM port, and that COM port will be used always, when you connect this chip/hardware (with this VID/PID). Of course, or until not change settings manually.
Ok, in the basic you need to do exactly same like with the cable. When you unplug and replug the cable you also must Disconnect and Connect your application.
If used App is not made well it may be necessary to completely close and re-open also used App. And in the worst case, when app after closing still block COM port (COM is still open and can not be opened again), you need to kill it in system’s task manager or restart PC.