If the brake light is on it could be dirty around the e brake got to go in there and clean around that area .also could be the brake sensor gunked up inside need to get the gunk out of the hole where the valve slides back and fourth then you hit the brake
Oddly enough I had the same issue. It fixed itself when I flushed the brake system. Could be part of the sensor in the reservoir reading too low fluid or was just contaminated.
It keeps the headlights on so that cars in front of you can see you. It is not needed for the car to operate. But it will be a headache rewiring all that mess.