This is a very common problem and is usually due to the selector switch. The one I mean is a three button switch located at the left of dash above headlight switch. Another cause may be the actuator on the transfer case. If you can swap out the switch with a freinds to check operation that would be cheapest. Then buy your own if this is the problem I suspect.