The budget is what the general voting public values NASA at for a given year, while the market cap of a firm is what the last sucker to buy a stock thinks it's valued at.
What the last buyer was willing to pay AND what the owners were not willing to sell for. What is the price America would be willing to sell NASA for? That's the market value.