recently I noticed that MacOS has become pretty unstable, in particular there is a new bug that is annoying me a lot. Since the computer has been started, it starts to collect some glitches on the screen, some of them blink and is very annoying, the situation get worse until the computer block it self or the OS crashes, this happens after two days usually. I was used to let my Mac powered on for weeks and now I have to restart it also three or four times in a week... I noticed also that sometimes the OS crashes due to video player in Safari, it happened some times that I was watching a video on the internet and suddenly the OS crashed causing reboot. I'll attach a picture of my screen to this message. These problems occur on my iMac (21.5" min 2011 with High Sierra 10.13.2) but I saw some other graphical problem during login on another my Mac (MacBook Pro 13" mid 2015 same OS version). There is a solution? Can I solve this problem without a clean installation of the OS? Thanks very much and have a nice day!
That is not a software issue. Your graphics card is getting inappropriate power. You probably have a capacitor or transistor that is dying (if you're lucky; if you're REALLY lucky you might be able to pinpoint the exact component by visual inspection) or the graphics chip is nearing the end of its lifespan.
If there is a shop that does board-level repairs near where you live it might be repairable, usually using donor parts from other dead boards.
Most often, instead of just dying one day, the glitches might slowly degrade to something like this.
I think on the 2011 iMacs the dGPU was a mezzanine card? I don't know if you would feel it is worth it to repair, maybe you could find a replacement for cheap.
If this is the integrated graphics, I don't think there is anything that can be done.
As for the MacBook, that's a completely different machine in terms of architecture, and not just for the GPU. Probably unrelated, but you could provide more details on what the issues on that machine are like in another question.