Question Computer randomly(?) freezes and I have to force shutdown ?

Jun 13, 2022
Specs: (MSI Infinite S prebuilt)
Operating System
Windows 10 Home 64-bit
Intel Core i5 9400F @ 2.90GHz 60 °C
Coffee Lake 14nm Technology
16.0GB Dual-Channel Unknown @ 1332MHz (19-19-19-43)
Micro-Star International Co. Ltd. MS-B9181 (U3E1) 53 °C
PHL 273V7 (1920x1080@75Hz)
Bosto Tablet (1920x1080@60Hz)
2047MB NVIDIA GeForce RTX 2060 (MSI) 39 °C
119GB Western Digital WDC PC SN520 SDAPNUW-128G-1032 (Unknown (SSD))
931GB Western Digital WDC WD10EZEX-22MFCA0 (SATA ) 42 °C
1863GB StoreJet Transcend USB Device (USB (SATA) ) 40 °C
Realtek High Definition Audio
Operating System
Windows 10 Home 64-bit

Hey, so this issue has started occurring in the last couple of weeks or so. At seemingly random times my computer will just freeze and not respond to any keyboard or mouse input, with the only option being to hold down the power button to force a restart. It feels like it occurs whenever I play a game, but it has happened when I'm not too which is why I'm saying it's kind of random. I thought it was an overheating issue initially but I've moved my pc away from the wall and I have a desk fan on it and that worked to help cool my old pc, but as you can see in the specs even when idle it usually sits around 50 degrees celsius. I also read that it could be a memory issue but neither of the tests I did (memtest86 and windows memory diagnostic) showed any errors. Any help would be appreciated as I can't afford to buy a replacement.