Since your MacBook was charging normally with the same cords earlier today, then the battery ran completely down, and it now switches between “Not Charging” and “Charging” about every two minutes, the first thing to establish is whether the Mac is maintaining a steady charging connection.
Disconnect the charger from both the MacBook and the outlet, and disconnect any other accessories.
Wait about 60 seconds, then connect the charger directly to the outlet and MacBook.
If you use USB-C, try another charging-capable USB-C port and check the port and cable for visible damage or debris.
If you use MagSafe, disconnect and reconnect the connector and check its indicator light. Apple: If your USB-C power adapter isn't charging your Mac laptop Apple: If your MagSafe cable or power adapter isn't working
Because the battery was completely depleted, leave the MacBook connected to power for a while.
Then shut it down, close the display for about 30 seconds, reopen it, and reconnect the charger. Apple notes that a very low battery can require some time before the Mac can be used again. Apple: If your Mac battery won't charge
Once it starts up, go to Apple menu >> System Settings >> Battery and note the exact charging message and battery percentage.
Apple points out that “Not Charging” does not necessarily mean that the Mac is receiving no power. Apple: If your Mac battery status is “Not Charging”
If it continues switching between the two statuses, check Apple menu >> System Information >> Power >> AC Charger Information.
This will show information about the connected power adapter. Apple: Mac power adapter information
If the charging status still keeps changing after these checks, the next step would be to run Apple Diagnostics, which can check the Mac for a possible hardware problem. Apple: Use Apple Diagnostics to test your Mac