The US military budget is an expenditure that occurs every year. Apple's market cap is the expected value of all of Apple's outstanding shares. These are really not comparable.
Just to be clear, those numbers aren't directly comparable. The market cap is the total value of the company, whereas the yearly budget is the cost for a single year.