If your Nintendo Switch console is turning itself off or entering Sleep Mode by itself, consider the following possible causes.
Are you leaving the console for some time without any input?
In order to save energy, the Nintendo Switch is designed to automatically enter Sleep Mode after a period of time when there has been no input from the user.
The default settings are: In TV Mode, your console will stay awake for 1 hour; in Handheld Mode or Tabletop Mode, your console will stay awake for 10 minutes without any input. To change these settings, please go to the HOME Menu and select "System Settings" → "Sleep Mode".
Has your console run out of battery?
Make sure your console is sufficiently charged before playing in Handheld Mode or Tabletop Mode. For details on charging your console, see here.
Is your daily play time restricted by the Nintendo Switch Parental Controls smartphone app?
If you have reached the set limit of your daily play time, the console will automatically enter Sleep Mode.
If none of the above resolve your issue, please contact your local customer service centre.