It obviously thinks that the wheels are turning at different speeds and engages the 4wd to ensure that they're not slipping. One of the sensors is likely sending an errant signal to the 4WD control module. Which one? Can't say. The first thing to do is crawl under it and look for any obvious signs of damaged wiring... Loose connectors, chafed wires, etc. on the ABS sensors at both front wheels and the rear diff housing.
The only way to know for sure exactly what's causing it is to have it scanned and watch the signals coming into the 4wdCM in real-time to see what sensor is out of whack.