Hello!
There could be a couple of things that are going wrong to cause the issue that you are having. The first thing that you should check is that battery cycle count. This will determine the battery life of your computer. The first link below has instructions on how to check this. The second thing I would ensure is that you are using a charger with enough wattage to power and charge you're Mac.
Determine battery cycle count for Mac notebooks: https://support.apple.com/en-us/HT201585
Find the right power adapter and cable for your Mac notebook: https://support.apple.com/en-us/HT201700
Let me know if this helps!