Don't forget the light also comes on if the parking brake switch isn't made. Small chance putting the brakes on flexes stuff enough to make that movement to close the switch if it's not quite being made when static
Parking brake switch makes a path to ground when the handle is pulled out, turning the light on. When the handle is in there should be a no gap between the switch and the shaft braking the path to ground
Applying the brakes would not effect the switch on the shaft.