OK one stupid question. Are you using a wireless keyboard and mouse? If so RFI {Radio Frequency Interference} could be the culprit and would explain why remote access works. In short if your mouse and keyboard is not getting it’s commands to your machine then you are locked out and it will not obey your commands. You could have several issues like this and DSL intermittent issues all compounding each other.
Wireless gear being interfered with doesn’t behave quite like this. Have 2 machines side by side with one having a paired Logitech mouse and keyboard, the other having a standalone Logitech mouse and a Kensington keyboard from the previous decade, closer to the previous century.
It’s actually fairly obvious when one device is getting low batteries, out of the Logitech gear. The interference is major and noticeable as skittering cursor on the mouse and dropped keystrokes on the keyboard. The Kensington keyboard just loses keystrokes to itself before going dead, but isn’t affected at all by the other three devices no matter how they’re doing.
Neither affects the connection at all for any device, wired or wireless.
Going back to the prior question about a failing mouse or keyboard. Windows isn’t at all shy about letting you know, with wired kit. You get the device disconnect/reconnect sounds each and every time they drop out and have to pick back up.