That is such an ignorant thing to say. You think Falcon 9 has had 500+ successful launches because they _think_ it will work?
The difference is that SpaceX is a private company that has the ability to iterate fast. NASA is a jobs program and Artemis/SLS a barrel of pork, simple as that.
SpaceX might design and build the nozzle, then put it in the rocket and launch it. It might work how they intended, or it might not, but they'll find out immediately. They'll make changes, build a new nozzle, launch another rocket, and continue until it works like they want.
NASA will do a lot more testing, simulation, redesigning, etc. until they KNOW that the nozzle will perform perfectly on the first try.
On the surface, NASA's approach sounds cheaper because you aren't wasting rockets. In reality it looks like SpaceX's approach might be better.
All components go through several test campaigns on the ground, while iterating on the design to address issues. These campaigns take months/years. That's why changes are stacked into "blocks", which are the equivalent of rocket versions. Each block must be certified by the Air Force and NASA to be deemed worthy of flying their payloads.
So while you're right that SpaceX doesn't typically do this sort of thing, NASA did pay them to fly an untested nozzle design.
1. https://en.wikipedia.org/wiki/SpaceX_COTS_Demo_Flight_1
2. See the section titled "Snipping the nozzle" at https://arstechnica.com/science/2020/06/forget-dragon-the-fa...