Just trying to be clear.
If you switch from 2WD to 4WD while driving then the 4WD light comes on and then goes off.
If you switch from 2WD to 4WD while stopped the 4WD light stays on(heres the part I am not sure about)
A. But as soon as you are driving it goes off
B. and it stays on even while driving
So A or B
If B, my guess would be the shift motor contacts are off a bit.
Inside the shift motor on the transfer case are contacts that move with the shift motor.
So when you shift to 2WD two contacts touch and 4WD shift module "knows" motor moved XX degrees.
If 4WD is selected then 2wd contacts separate and 4WD contacts touch if motor moves far enough.
Look here: Servicing A Transfer Case Shift Motor
First picture shows the Blue cover with all the contact wires going in, 5 I believe.
The Blue cover has slotted holes, and 3 screws that hold it in place.
And there are line up marks on the edge.
If this Blue cover has moved a little then when driving the shift motor might only be able to move the shift rod 89 degs because of resistance in spinning transfer case, but when stopped it moves 90degs.
So barely makes contact one way and firmly makes contact the other way.
It is in 4WD it is just the electrical connection that is off