Does the 4High or 4low light go OFF when it comes out of 4WD?
Assuming electric shift
The shift motor on the transfer case uses a worm gear drive so can't slip unless drive is broken
Inside the shift motor assembly are 4 position sensors that tell the 4x4 controller(GEM Module) what position the shift motors drive is in which should be what position the transfer case shift rod is in, 2H(2WD), 4H or 4L
Position sensors are what activated the lights, via the GEM, there are no sensors inside the transfer case
Position of shift rod seen here:
https://www.therangerstation.com/tech_library/images/rebuild_transfer_case_shift_motor/rebuilding_a_ford_transfer_case_shift_motor-2.JPG
Shift rod is pointed at 2H in the picture
Its possible for the 4 position sensors to be "off" a little
So when 4H is selected the shift motor moves to 4H but its not fully in 4H, just on the edge of 4H, so it can "slip out" of 4H
You can remove the shift motor and plug it back in, then select 4H on the dash switch and see if the triangle drive is correctly pointed or if its off a few degrees
Also check that the triangle drive is not cracked or other wise loose
You can also use vise grips to manually turn the shift rod to 4H then clamp or tie the vise grips into position to hold the shift rod, it WILL move back to 2H on its own, there is a spring inside transfer case
Then go for a drive and see if it still "pops out" of 4H, if so then problem is in the transfer case, it will need to be pulled out and repaired
Its a BW1354 transfer case if you want to see what inside it