Hi
When a device starts behaving like this it usually means that your batter is needing replaced
Leaving lithium battery’s sitting for a long time can cause them to degrade and stop working properly
Also the temperature and amount of battery cycles has a lot to do with it too
Here’s how to check your battery’s health(linked below)
[link|https://m.youtube.com/watch?v=YN0CO1hqDAU|https://m.youtube.com/watch?v=YN0CO1hqDAU|new_window=true]
If your cycles are above 500 and it says service anywhere that usually means that the battery is the issue
Here’s a link to the part you may need
[link|https://store.ifixit.co.uk/products/macbook-air-13-late-2010-2017-replacement-battery|https://store.ifixit.co.uk/products/macbook-air-13-late-2010-2017-replacement-battery|new_window=true]
Hopefully this helps
Any questions please ask
Thanks:-)