I suspect you either have bad or incompatible memory, or a failing hard drive.
Macs are very picky about the memory they use, so it is best to only use memory from Crucial or OWC. When purchasing memory, make sure to use the tools on their websites to identify the exact part numbers that are guaranteed compatible with the exact model of the Mac. Never buy memory based solely on technical specifications (even from Crucial) because there are tech specs (secondary timings) that Apple does not provide that are necessary for full compatibility.
You can check the health of the internal hard drive by either running DriveDx (free trial period) while booted into macOS, or GSmartControl when using Linux (some Linux distributions may require you to install it from the distribution's software repository). Post the complete text reports here using the "Additional Text" icon which looks like a piece of paper on the forum editing toolbar.
You can try checking the memory by creating & using a bootable MemTest86 USB stick. If you don't get any memory errors after running several four pass scans, then try adjusting the MemTest86 CPU settings to "Round Robin" and "Sequential" to see what happens. I have found on older Macs that the other Memtest86 CPU settings will sometimes alert to a problem...such as the system freezing. I haven't run custom settings on a 2010 iMac so I cannot be sure those custom settings are compatible since I know on later models 2017+ those custom settings cannot be used, but other older Macs work fine with those custom settings. Keep in mind if MemTest86 freezes with default settings, then it indicates a hardware issue (with custom settings you will need to see if any memory configuration passes -- best to try using just the original Apple memory to compare results).
You can try running the Apple Diagnostics, but I doubt it will find any issues unless those issues are really severe.
Keep in mind an OS installation stresses an old hard drive & can reveal latent issues that went unnoticed while using macOS. Plus Linux may utilize the hardware a bit differently than macOS which can also reveal existing hardware issues that went unnoticed while using macOS.
You can try installing Linux onto an external USB3 drive to compare results. If the Linux installation completes & boots fine, then it would tend to point to the internal hard drive being bad. If installing Linux to an external drive has issues, then it points more towards a memory issue.
The easiest way to eliminate possible memory issues is by removing the third party RAM and reinstalling the original Apple memory.