Is engine temp always warmed up or always cold when it happens?
Has fuel filter been changed in the last 5 years?
If not I would do that
I would GUESS a fuel issue just from elimination
Spark issue would have to effect all 4 spark plugs at the same time
Compression is mechanical so intermittent is not usually seen
1998-2011 Rangers run 50-60psi fuel pressure
And should hold pressure above 30psi with key off for several MONTHS and MONTHS
For safety reasons the fuel pump only runs for 2 seconds with key ON
It won't start again until RPMs are above 400-500, cranking speed is 200rpms
Or unless key is cycled off and on again to get another 2 seconds
Each 2 seconds adds about 10psi to static fuel pressure
If you are losing fuel pressure when key is off then restart would have the symptoms you describe
Assume 0 psi and then 10psi key on, barely enough to start engine, and if rpms stayed low then stalling
There are 4 things that hold pressure in the fuel system, key off
Fuel lines of course but you should SMELL leaking gasoline
Fuel injectors, but drastic drop in MPG would be noticed with a leaking injector
The other two are inside the gas tank
Fuel pump has a check valve inside it, when pump is off it won't let fuel flow backwards into the pump/tank
FPR(fuel pressure regulator) its on the end of that 3rd hose on the fuel filter, set for 55psi, just a spring valve so could leak but just into the tank so no smell or drop in MPG
Intermittant is odd but not unusual as something fails