No power or ground is at the shift motor unless the 4x4CM is active, sending it 12v and a ground, these reverse to run the shift motor in two directions
In 2001 the 4x4CM is behind passenger side kick panel, it was a common failure point in the 2001 to 2005/6 Rangers and Mazda B-series
Looks like this one:
https://www.ebay.com/itm/OEM-NEW-4x4-Transfer-Case-Shift-Control-Module-Ranger-Explorer-1L5Z-7E453-AC-/191593496579
I will post wiring diagram below
But its basically pretty simple
The dash switch is 3 resistors and rarely breaks
The 4x4CM sends the switch 5volts with key on
If 4x4CM gets back 4v that means switch is set at 2WD
3v is 4High
2v is 4Low
The 4x4CM has 2 relays inside, one for each shift "motor" wire, BOTH relays are Grounds when open<<important
So the 4x4CM only needs to activate 1 relay to send 12v on one wire to get motor to turn clockwise, other wire is already a ground
And then activate the other relay to get motor to turn Counter clockwise, simple
The shift motor's worm gear turns the shift rod gear which has a 4 contact "wheel", so 5 wires
The 4x4CM uses the contacts to tell the position of the transfer case's shift rod, 2wd, 4h or 4l
So 7 wires total, brown wire was for an electric clutch
If you change the switch position and do not hear the 4x4CM "click"(relay) then 4x4CM is most likely the issue
But if you don't activate the shift motor once a month they will fail
Shift motor rebuild info here:
https://www.therangerstation.com/tech/rebuilding-a-ford-transfer-case-shift-motor/