I'm not sure what the problem is but try resetting all the Photoshop settings to default.
As soon as you click to start Photoshop, Press Ctrl Alt Shift (Command Option Shift) and then click OK to delete settings file.
This will set Photoshop to the default settings. If this doesn't work, then you at least know that it is not a setting that you accidentally enabled.
Restarting Photoshop on its own temporarily fixes the problem, but then it just happens again sometime later.
Are you using a Wacom tablet? This could be an issue with the driver of the tablet. Try to disconnect the tablet. If the issue is solved reinstall again the Wacom drivers
I am using a Wacom Cintiq. But neither the pen nor the mouse can draw a line when this happens.