The circuit for the light to go on is made by the switch in the pedal moving forward (its a spring loaded mechanism). In essence as there is a gap between the two wires that creates the circuit.
You could have a:- break in one of the wires, a broken switch, crap in the switch or pedal or frayed wires in the rear light unit.
Its a process of elimination, take a look at the light unit with a tester, then proceed to check the switch out in the pedal. Disconnect the wires and join them together, the light should go out, if i doesn’t then trace the wires back to the back light.
I bet you find its something really simple hopefully