According to Elon Musk the biggest single difference is the economic incentives of fixed priced bids (SpaceX) versus cost+ bids (traditional aerospace).
With traditional NASA bidding procedures there are very few to no incentives to contains costs. Military procurement has the same issue, combined with stringent requirements that preclude off the shelf for virtually anything. (Off the shelf is not, of course, an option for SpaceX. But if it was, they would likely consider it!)
NASA's definitely hampered both by organizational and political issues that SpaceX isn't, but as other posters have pointed out NASA has also managed to do some amazing things on a comparative shoestring budget in recent years and -- unlike SpaceX -- these are things no-one has ever done before with relatively few failures.
With traditional NASA bidding procedures there are very few to no incentives to contains costs. Military procurement has the same issue, combined with stringent requirements that preclude off the shelf for virtually anything. (Off the shelf is not, of course, an option for SpaceX. But if it was, they would likely consider it!)