Your battery swelling means that it is done for. Depending on a number of factors (age of the device, your available budget, etc,) it may be practical to have the battery replaced.
How does this happen? Usage habits would be the most common. These batteries have a finite number of times that they can be charged (usually several hundred) before they will begin to swell/fail. Once you exceed that number you will notice swelling.
Not using an approved charger would be another. I have had many customers tell me that their aftermarket chargers no longer work on their devices. That, actually, is a good thing. Every device manufacturer goes to great lengths to make sure that we have a quality product to enjoy, so it is always a good idea to use the recommended products and kudos to apple for ensuring that only approved chargers works.
Overcharging is a third cause. There are a number of “smart chargers” out there, and I believe that the OEM Apple Charger is one of those, that will actually stop sending a charge when it detects that the battery is full. If yours does not, charging overnight is a bad idea. Most devices don't actually take more than 6 hours to charge and you would be amazed at what the extra time on the charger can do if it continuously feeds juice into the phone/tablet.