Start with the obvious first...check your battery terminals are done up nice and tight... I recently watched a vlogger on youtube that had a very similar problem.. he checked pretty much every switch on his bike before finding his battery was loose!
Failing that could possibly be a faulty sidestand or cut off switch perhaps?
Hope you get it sorted soon ☺