If your Mac is behaving in an odd way, there may be an issue with some piece of the hardware -- such as the RAM.
You can perform a hardware check in order to chase down a diagnosis.
- Shutdown your machine
- Boot your machine
- While it is booting, hold down the
d
key
At this point, the machine should have booted into a special hardware check mode. Select your preferred language, the hardware check will be performed, and any issues will be reported.
h/t Dillon Hafer