SpaceX has a very different set of risk tolerances and approaches. Nasa is a government funded entity and the tolerance for failure (rightly or wrongly) is very low according to every thing I've read.
SpaceX being private has a much larger cushion for failure. Elon will keep funding it far longer than congress would Nasa is my guess. If SpaceX loses some rockets that's the cost of business, of course once those missions are manned it's a huge difference but until then I think it's not really comparable.
You have it exactly backwards. Risk tolerance is higher for the government. Fox example, SpaceX would never just send a rocket to mars just to do science which would bring it zero profits. It won't take risk funding something where the science may or may not bear any fruit.
As you can see, SpaceX was so cash strapped in 2017 it obviously didn't go to mars in 2018 as they wanted. Also notice Elon didn't fund that trip (otherwise it would have happened). There is no way he would risk HIS own money on that.
Main reason for Red Dragon not happening was NASA requesting parachute landing into the ocean instead of the previously planned propulsive landing on land for Dragon 2.
This would mean that SpaceX would need to develop and fund Dragon 2 propulsive landing on their own, with only real mission fully requiring it being Red Dragon.
In the end it was much easier to just drop the whole thing, especially with the much more perspective Starship on the horizon.
SpaceX being private has a much larger cushion for failure. Elon will keep funding it far longer than congress would Nasa is my guess. If SpaceX loses some rockets that's the cost of business, of course once those missions are manned it's a huge difference but until then I think it's not really comparable.