MacBook Pro shuts down when connected to power (more in description)
As the title says my MacBook Pro (which I've had for around 14 months) keeps turning to black and shutting down on its own. As of Thursday, it shuts off when I plug it in and then turns back on after I press the start button. It also goes black and shuts down immediately when I unplug it. It charges fine, and though it shuts off when I plug it in, it does not shut off again while charging. Another odd thing is that the laptop works for long periods at a time without shutting down (I don't know if it has anything to do with overuse?). I started having this problem on Thursday, August 31, but then it seemingly fixed itself overnight and I had no problems with it for around a week, when this issue started happening again, but only sporadically, and only really in relation to charging. (as I said, it shuts down when I plug it in, and shuts off again when I unplug it). I took it into the school IT shop, they said it might be spill damage but I've never spilled anything on it*, and I don't think that accounts for the periods of usage without issue. I also do not have any other of the issues described as being common. Other than this my MacBook runs completely fine and is not slow nor does it have issues with volume, etc.
I've googled this quite a few times and I've seen things from RAM issues to overheating. But none of those really make sense, and I've checked to make sure those weren't the issue. My dad has a PC and said it could be battery issues but my battery health is at 97%, and again this does not account for the long periods of usage without shutting down. My best guess is overheating, especially since it's been extremely hot on my campus and my room does not have air conditioning. However, it just shut down in the library, which is very cool.
I'm sorry for such a long post but if you have had this problem before and know what it is that would be so extremely helpful.
*For transparency's sake, I did use a wet wipe a few days before this issue started happening, but it was at least four days prior, and I'm not sure that spill damage could account for the periods of long usage I've been able to have.
MacBook Pro (2021)