A Raptor is expected to cost less than $1M each.
Blue Origins BE-4 is priced at $8M each.
So how did conservative NASA get cheaper RS-25 engines for only $147M each?
It was enhanced for Falcon 9, which has a total development cost of $300M for the first versions, including rocket, tanks, second stage, Merlin Vacuum.
The RS-25 was developed in the 70s for the Shuttle, and had a quoted cost of $47M at end of Shuttle life. This is literally the cost to make a few more after all design and testing was done. NASA has spent over $15B developing the SLS, why are they paying three times more for these engines?
Merlin is much simpler and smaller and not really comparable to the other two.
The RS-25 got new life with SLS, I would expect future NASA craft to use Space X engines.
https://en.wikipedia.org/wiki/Space_Launch_System
So they reused as much of the space shuttle as possible, down to using left over engines. Developing a new engine from scratch using a new fuel (methane) like SpaceX did would have been a very risky proposition. Like NASA, Blue Origin and ULA both did much more conventional things and have launch costs multiple times those of SpaceX. The relative cost of NASA's more conservative design decisions is more a testament to Space X's remarkable success with the Raptor engine than NASA being somehow incompetent.