Since it occurs on both internal and external displays you either have a hardware issue with a bad Logic Board (has CPU, GPU, Memory), or you have some sort of third party software/driver issue. The only way to confirm you have a hardware issue is by running the laptop with a clean install of macOS. A clean install is to completely erase the whole physical drive before installing macOS and testing the laptop before migrating or restoring from a backup or before installing any third party apps. You can install macOS to an external USB drive if you don't want to touch the internal drive.
You can also try running the Apple Diagnostics to see if any graphical glitches occur on the screen or if the diagnostics report a hardware failure.