I have to say, in general this doesn’t happen too often. But if you are afraid of this scenario specifically, my advise is either use a separate partition for the home folder (this is where all user installed things go, as well downloads, documents and pictures by default) and make a backup in some other drive with something like timeshift, or use something a bit more advanced namely immutable distro. I will give a bit of advise here: immutable distros can be extremely unintuitive, so if you want to try and understand it, go for a VM and take a weekend playing around. For gaming, bazzite comes to mind for this specific case.
I have to say, in general this doesn’t happen too often. But if you are afraid of this scenario specifically, my advise is either use a separate partition for the home folder (this is where all user installed things go, as well downloads, documents and pictures by default) and make a backup in some other drive with something like timeshift, or use something a bit more advanced namely immutable distro. I will give a bit of advise here: immutable distros can be extremely unintuitive, so if you want to try and understand it, go for a VM and take a weekend playing around. For gaming, bazzite comes to mind for this specific case.