There is a bit of your Apple computer that is called the System Management Controller (SMC), and it controls some hardware functions so that the otherwise busy main processor can be left to work on more important stuff. This piece of hardware sometimes malfunctions and your Mac will start to behave very strangely. Such as when the laptop’s fan goes on at full speed even if it’s properly ventilated. Or the MagSafe light goes out and doesn’t come on again even if your Mac needs charging.
There’s a whole bunch of quick diagnosis things you can do to understand whether you should think that the SMC isn’t working well. Click and read this Apple Support page to read all about these and about how to easily reset the SMC to get the whole system to work peacefully again.
I did it on my Macbook Air and it works. Read the support page before proceeding further.