This sounds like a video system issue, which unfortunately wasn't uncommon on the 2011 models. The graphics chip starts to degrade with repeated thermal cycling, causing an eventual failure that appears to the user as an intermittent shutdown, an inability to boot up, a black screen, loss of video or corruption (coloured blocks, lines or other patterns, video shifting left or right on the screen, or screen tearing).
Any Apple Store or Authorised Service Provider can run a diagnostic test on the machine to confirm the issue, which typically takes around 15 minutes maximum to complete. There shouldn't be a charge to run the test but phone ahead to wherever you intend to take it to be sure.
If the graphics hardware has failed, then a replacement Logic Board would be required to correct the issue - however Apple discontinued the supply of parts earlier this year, so sourcing one is now becoming difficult. Even so the replacement boards Apple was supplying were only refurbished units, and the replacements often failed again after a few months.
I wouldn't expect second hand replacements to be any better, and while some services on eBay and the like claim to offer a board repair service to "reball" or "reflow" the chip, I find this often isn't a permanent repair either - because AMD doesn't make new 2011 series Radeon chips, most of the replacements are just recycled parts scavenged from other boards.
The best bet would be to use the computer as long as it remains functional, but start considering the possibility that a new (or good condition used) computer may be needed in the near future.