A 2010 Mac is now considered "Obsolete" by Apple so no official repairs are available.
Try booting into Safe Mode to see whether that allows you to use the laptop a bit longer. If so, then check to see whether there are any Kernel Panic log files in "/Library/Logs/DiagnosticReports". The Kernel Panic log files will have names beginning with "kernel", if they exist (sometimes they are not always saved). Post several of the Kernel Panic logs here using the "Additional Text" icon which looks like a piece of paper.
The 15" model is known to have GPU issues, so this is a very likely cause, but there are other things which can cause this problem as well such as bad memory or a bad memory slot on the Logic Board. You can mostly eliminate a bad memory slot by removing the memory module nearest the Bottom Case since this slot tends to develop cracked solder joints due to pressure on the bottom case. Sometimes the other memory module nearest the Keyboard can become unlatched especially after a memory upgrade. Even a failing drive can cause an unexpected shutdown, but it seems like this laptop is having a Kernel Panic.
Are you sure it is powering off, or could it be the display is going dark? Press the Caps Lock key to see if the Caps Lock LED lights up which usually indicates the laptop is still on & running. Is the front LED on, off, or flashing?
You can try running the Apple Diagnostics to see if any hardware issues are detected. The only useful diagnostic is one which reports an issue or one which freezes the system during testing.
If it is a GPU issue, then you can try forcing the laptop to use the Intel GPU instead by using gxCardStatus:
https://gfx.io/
https://github.com/steveschow/gfxCardStatus/releases