"SpaceX has entered into an agreement with NASA for a Dragon mission to Mars" -- NASA is footing the bill.
Government contracts are often quite profitable, not to mention the technology and reputation gains SpaceX would realize from such a mission. I would expect investors to be thrilled with this announcement.