i use to have the same problem it might be that you installed a software that has a bug into your Mac what you can do is when you restart your computer before your screen starts you press the “apple + option +R + P” all four buttons at the same time that’s when your computer is going to restart which going to refresh your hard drive but if your Mac keeps doing that then your going to have to send it to apple to replace your hard drive because the bug has probably affected your computer