I am suspecting that when the hatch was changed they didn't change the rekey nor match the wiring and internals. Just like T4topher is thinking too. Explains bizarre behavior if this is the case. Not your fault though.. First is to isolate what the wiring is that is in your back hatch.. Then verify if it matches your Rig.
[In case someone comes across this in the Future]
Rule of Thumb is always keep the wiring that matches the chassis to make your life easier.
If the wiring is correct and its only the key. I would check the boot and the top for broken wires cracked insulation etc as that is a very common area to have issues was well. :-)
[Wiring]
Early years 96-98 really close. 99 to 2000 transition 2001 - 2002 really close.
So depending on which hatch was put on from what year can explain this bizzare issue..
Can you see any wiring harness part numbers or controller part number that may help you on your quest of identification.
__________________
7 3rd gens listed in the build thread (2 are parts mobiles)
Build Thread:
https://www.toyota-4runner.org/3rd-g...os-builds.html
Brillo's Bucket Fluid Ex changer:
https://www.toyota-4runner.org/3rd-g...ml#post3358086
Sparks Plugs Wire and Coil Information:
https://www.toyota-4runner.org/3rd-g...on-5vz-fe.html