Could anyone please inform me in which case(s) SharePoint groups will NOT be deleted when a site or subsite is deleted?
OOTB when a site is deleted all the groups corresponding to that gets deleted. I think your question was mainly targeted towards inheritance of the Permissions of the Subsite from Parent. incase of subsite the groups created in below scenarios will get deleted.
-> if the subsite breaks the inheritance and adds its own groups -> Setups the OOTB groups ( vistors , Members , Owners)