Have you tried replacing the cable - I know this can be painful for a Thunderbolt 3 cable, but replacing a USB 3.1 cable is probably not that expensive.
If you’re talking about physical fit, the metal enclosure from a USB-C cable to my 16" Powerbook is pretty snug - a little less so on my 2020 iMac. My 2017 iMac is virtually identical to the 2020 iMac - which may be part of the reason the iMacs lose connections so easily.
Have you tried blowing out the contacts and plugs with compressed air and mounting the time machine disk, deleting the snapshots, and running disk utility on it?
Once you have a solid connection to the disk blowing away snapshots - you can do this with Carbon Copy Clonder if you have it - can sometimes clear up disk problems because the snapshots tend to get corrupted more easily than the disk volumes.
Unfortunately though, time machine is not a bullet-proof backup/archive mechanism.
Occasionally you simply have to reformat the disk and start over.
I keep four backups: a Carbon Copy Cloner backup taken nightly, a local time machine disk, a time machine on a Synology located elsewhere on my LAN, and a Backblaze backup located out in the cloud.
In fact, my local array is kept backed up on the Synology and in Backblaze - a real bargain considering I have 34 TB stored out there .