Their goals are similar, NASA is just hamstrung by Congress and the general public. If NASA had the freedom to choose its direction they too would be working on a Starship style rocket by now, not attempting to pass off a dinosaur as modern.
> NASA is just hamstrung by Congress and the general public
I don't think you can assert that NASA hasn't or wouldn't fall to Pournelle's Iron Law of Bureaucracy. What makes NASA special to be immune to such dysfunction?
SpaceX is a profit motivated company with large degrees of flexibility. They move fast and break ships.
NASA is a research institution focused on scientific advancement and space research. They also are very rigid due to the way they receive funding. NASA cannot afford to move to a starship style system because the SLS contract was locked in.