Welcome to TRS
2002 and up Rangers had the Mazda L 23NS Duratec engines
2002 and up Mazda B2300 used the same engine
These engines showed up in Rangers in mid-2001, so you will see 2001 Duratec Rangers
But all 2002 and up had them
2001-2003 2.3l Duratec had Electric thermostat and IMRC(intake manifold runner control) these both needed computer feedback or control
2004 and up lost both the above, so 2004 2.3l and up computers are different that 2001-2003 computers
Any 2004 to 2012 23NS Duratec should/will work fine in your 2005, if you are willing to change some parts from one engine to the other.
Sensor plugs and placement change on the engines over the years, so a 2005 sensor plug might not fit on to the 2007 sensor, just swap sensor over, or sensor was moved so 2005 wire won't reach, extend the wire
The NS in 23NS stands for north south, it means the engines were mounted Rad to Firewall, and these engine were made in Dearborn, Michigan
Ford cars got the 23EW, east west, these engines were mounted wheel to wheel, transverse mounting, and made in Mexico
Ranger needs a 23NS not a 23EW