"The good news out of all of this is that I tried a different power cord with the Mac and it hasn’t been shutting down (the cord that comes with the Mac)."
So... during the times it was shutting down intermittently... we you always using a DIFFERENT (3rd-party) power cord?
And... the problem went away with the original/factory cord?
Sounds like a simple connection/disconnection with the 3rd-party cord to me.
Sometimes [what we think to be] complex problems turn out to be "not so complex".
Sometimes a "simple solution" is all that's required.
With a 9-year old Mac, have you given any thought to the new Mac Studio...?