Spacex was from its start conceived by Musk to develop low cost systems that will be used to colonize Mars. He has said this from the start.
Nasa contracts were never necessary for SpaceX to succeed as they have contracts world wide to lift payloads to space for many nations. These contracts help to accelerate the company timeline for crewed missions to the Moon and Mars.
"Red Dragon is a modified SpaceX Dragon capsule for low-cost Mars lander missions using Falcon Heavy rockets. Plans call for a sample return rover to be delivered to the Martian surface while also testing techniques to enter the Martian atmosphere with equipment a human crew could eventually use."
[1]: http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/2012001...