Strange thing happening to one of my older Macbooks, and have tried just about everything. It will charge just fine if I leave it alone, but charger turns on and off repetitively as soon as I start using the Mac while it's plugged in. Tried installing a new charging port and did not solve the problem, has a new battery too that is third party. Did reset SMC, and tried different chargers but no luck. It's a 17" from all the way back in 2010, but has a Quad Core i7 with 16GB of ram so would love to keep using it.
Could be the battery, could be the charging circuitry on the motherboard, could be the charger. Getting to be too old to spend money to fix, at this point. Best just to "come to an accommodation" with things as they are, and get along that way.