Hello, katharinasunshine. Thank you for posting to the Apple Support Communities. You’ve come to the right place for help with your Macbook Air.
We understand that you have noticed your Mac powering off or restarting automatically while you use it. Something like this could be caused by several factors and we’re happy to help you research any possible solutions.
To start with, we have a list of suggested troubleshooting steps to use first. Please read over the following Apple Support help article and complete each step listed:
If your Mac restarted because of a problem - Apple Support
We can help you more if you continue to notice the same issue after completing the steps from the article above.
It would be helpful to know how your Mac operates while started in safe mode. Using safe mode can help us isolate this issue to either software, or a hardware cause. The following article explains how to use safe mode with your Mac:
How to use safe mode on your Mac - Apple Support
We look forward to your reply and to helping you more with this issue.
Cheers!