Same behavior on both of my Macs (Air and Pro), they would indicate to be charging but then disconnect from charging in few seconds interval until the m1-Air just died and couldn't charge it anymore. M2 also stopped charging so I sent them both to the service center.
Has your charging issue been resolved though?