Joy-Con connection loss with the console can be caused by both software and hardware issues:
Signal interference — Joy-Cons use Bluetooth, and nearby devices (routers, smartphones) may disrupt the signal.
Low battery — when the controller is nearly discharged, the connection may become unstable.
Attachment problems — in handheld mode, the console rail and Joy-Con contacts can get dirty or worn out.
Outdated firmware — both the console and the controllers receive updates that fix bugs.
Antenna defect (especially in early versions of the left Joy-Con).
What you can do:
Update the Switch and Joy-Con firmware via the Settings menu.
Fully charge the controllers and try again.
Clean the rails and contacts with a dry cloth or cotton swab.
Reconnect the controllers via Settings → Controllers → Disconnect Controllers.
If only one Joy-Con keeps disconnecting, it’s likely a hardware defect — better to contact a service center.