I have a Sony Vaio laptop. No matter what the battery percentage, and whether it is currently charging or not, it will automatically shut down and rebooting automatically will again turn the laptop off, thus I have to wait some time. There will be 1 or 2% charge after rebooting. I taped the charger which was loose and it seemed to fix the issue until a few days later. I cannot save any work that I do when it shuts down like that. I cannot take out the battery for some reason, if you can help me with that that would be great.
It sounds a lot like you may have a two fold problem. First, the battery is going bad (which will give false charged readings) and second, the charger being damaged (your need to secure it).
The only way to fix these problems is going to be to replace the parts, and be sure you replace them with OEM parts rather than aftermarket, which can lead to a whole other host of problems. Those may be cheaper, and they may be fine for certain things, but aftermarket stuff is not worth the risks in this case.
OEM stands for Original Equipment Manufacturer. As in the parts made for/by the company that you got the laptop from. So in your case a true Sony battery/charger. Anything other than this would be aftermarket.
If the charger is not the problem then the port could be. Having to 'secure' the charger to the laptop in any way is not normal. And if the charger you bought is aftermarket, then it may not actually sit right when connecting.