I had the problem of the random squares, getting progressively worse, etc etc. on my early 2011 MacBook Pro. Apple replaced the motherboard around 2015 and that worked until it didn’t.
I ended up replacing/upgrading the motherboard to a used mid 2012 2.3 GHz Intel Core i7 board (last powerbook before retina displays). I understand that Apple corrected the GPU problem on that version. The replacement was a direct swap out, though the one I got had the fans, heatsinks and thermal conductors still attached. I recall reading that if you use the old thermal equipment on the newer board, there was something that needed adjustment (mechanical, not electrical), but with all the thermal equipment still attached as a unit, it was just out with the old one and screw in the new one. Anyway its been working great for about 6 months and counting. The the mid-2012 board also has newer/current versions of USB and bluetooth, so this was a great upgrade—airdrop now works with IOS devices for example. Also, I transferred my 2each x4Gb 1.33Ghz RAM chips to the new motherboard and that works fine. The 2012 mother board is supposed to be able to handle up to 2eachx8Gb, 1.6GHz chips. (Just ordered those). The Thunderbolt connection to a big apple display is fine, and the computer is running cooler and quieter. This seems to have solved the GPU problem and given me a “new” computer that is very capable and relevant.
The swap out was fairly painless, however the screen cable (sorry I forgot the proper name for it) has a very large number of conductors on a very delicate connector. It was somewhat difficult to get that reconnected properly. The first time I assembled it, the screen did not work (though the connected monitor did). I tried again, being vary careful to clean and blow dry the connector and cable (a jewelers loop helped), with success. The only other issue was that some of my internet accounts and wi-fi connections saw this as a new computer and I had to re-register into those. This turned out to be a lemonade out of lemons story.