Normally the charging socket has a switch that operated when the charger is plugged in. The switch disconnects the battery from the motors when the charger is plugged in. This prevents the charger from being connected the motors. This is necessary because the load from the motors may be too great for the charger and running motors from the charger may over load and damage the charger,
I think this is most likely
The yellow is the Positive feed to the motor control PCB and motors
The red is the Positive to and from the Battery.
The black is the negative to the Battery and the PCB.
Without the charger plugged in the yellow is connected the red in the socket thus battery Positive is connected to the PCB
When the charger is plugged in then the yellow is disconnected from the red thus the motor control PCB is disconnected from the battery and charger.
I think this is most likely
The yellow is the Positive feed to the motor control PCB and motors
The red is the Positive to and from the Battery.
The black is the negative to the Battery and the PCB.
Without the charger plugged in the yellow is connected the red in the socket thus battery Positive is connected to the PCB
When the charger is plugged in then the yellow is disconnected from the red thus the motor control PCB is disconnected from the battery and charger.