hi there,
I am having the same problem with my Macbook Air 13 inch late 2015. I spilled some soup last year, but I cleaned it up quickly, and assumed everything was fine. Over the year, the screws on the bottom of the mac fell off and the base became a little loose. Then, after returning to my mac after 1 month+ of inactivity, i found out that the mac randomly turns off when I unplug. I found this discussion really helpful and will try to get my mac to a computer shop. It’s a school computer, but idk if the IT can be able to fix it.