It seems that your charger or computer hardware caused your Mac malfunctional. So please try connecting the charger to another USB-C port and test if it can manage to charge your device.
Or take your macOS device and charge cable to the nearest Apple store or Apple Authorized Service Provider for professional diagnoses.
Good luck~