The F-35 is used for defending airspace, a doubly-federal duty. Spreading the spending so widely is a purely political gambit (I believe pioneered by NASA with the Space Shuttle).
Although expensive, it wouldn't surprise me if the F-35 was financially profitable for the US.
The F-35 jet program accounts for about 27% of Lockheed's revenue
Lockheed financials: 2024 net sales $71.0 billion. Recorded pre-tax losses of $2.0 billion associated with classified programs
Returned $6.8 billion of cash to shareholders through dividends and share repurchases in 2024
Total Assets @Q1 54.96B
$110.94 B Marketcap
Nearly 80% of the $46 billion in revenue in 2014 was generated from purchases by the US government
Total foreign ownership of US companies is about 40% (I wonder if total US ownership of foreign companies exceeds foreign ownership of US companies?)
Sourced above by variety of sources - likely inaccurate.
Total costs (e.g. externalities, political) and benefits (e.g. security, influence) are harder to guess at.
The US political system puts a huge amount of pressure on allies to buy US armaments. The US military industrial capitalism is complex, and has massive political backing. Christmas lights sell missiles. I also wonder how much of the F-35 profitability comes from a Gillette/SaaS/HP financial model? Wars destroy capital goods, which is great if you're selling them.