Since it is random try check the following and allow a bit of time to see if it happens or not.
Can you hear the fan is working OK and feel the air from the air vents in the laptop case? This is in case it is overheating and shutting down. If you can’t hear or feel the fan it may be faulty or the vent is blocked etc.
Check in Event Viewer for any Critical, Error or Warning events that may be logged at the time of the shut down. To get to Event Viewer in Win 10 press the Win key + x key (both together) and click on the link. Search online using the Event ID and Source information to find out what it means
Start the laptop in safe mode with networking and see if it occurs.
If it doesn’t it is a driver problem as only generic Windows drivers are loaded and not the hardware specific drivers for the laptop.
If it still fails in safe mode then try getting into BIOS on startup and leave it there and check if it also shuts down when there.