Often this is a loose connection at the top of the battery. There is a plate on the bottom of the frame that can be adjusted to put more upward pressure on the battery/frame connection at the top. It holds the battery in more securely. If the battery is bouncing, it may momentarily disconnect, shutting the motor off and requiring a repower.
The light may be a wiring issue in the downtube near the frame headtube or a problem in the light itself. On my 2015 Specialized Turbo, I ended up replacing the light because the wire from the frame to the light was damaged.
Finally, one of the battery failure modes that I experienced a few years ago was the battery cutting out. This turned out to be an actual battery failure. The issue is that these are no longer available as far as I know. I ended up replacing my 462Wh non-bluetooth battery with the 691Wh bluetooth battery from a Turbo S. Mission Control now works on my bike and I have a range of around 80 miles.
Good luck.