Could you please try different mode for connection on the STM32CubePRogrammer (hot plug, under reset). If it does not work, disconnect your board, restart the STM32CubeProgrammer and reconnect the board. Also, try different cables (data and not charging cable), USB port, ..
Hello , we have tried all the things mentioned so please do let me know if there is anything else that I can do. Also help me understand why the stm32 target device is not detected.