To be honest most of the "credit" comes from Wall Street. Yes, Tesla wouldn't have been profitable if you subtracted the credits but it is absolutely not worth as much as the market says with the credits or even with 3x the credits it got.
And the $TSLA price it's not just some random number mostly irrelevant to daily operations of the company, they sold/issued many shares at such valuations.