To your point, in Jeff Bezos' 2004 letter to shareholders(1) he writes about how free cash flow and GAAP profit are not the same. It's easy to assume that profit would be the same as how much more is left in the bank at the end of the year vs. the beginning of the year, but it's not. And understanding these things illuminated how Amazon was operating.
I joined Amazon shortly after this letter, and internally the strategy was to minimize profit as the IRS would calculate it in order to pay no taxes while maximizing free cash flow. And it was built as a conceptual "dial" that Bezos could turn at any time to start making a profit. Wall Street did not understand this about Amazon for close to a decade after the dot com crash (or half a decade after he broadcast it in this letter).
As a result, Amazon's stock was hammered because investors thought Amazon couldn't find a way to make money. All the while, they were plowing tons of excess money back into long term bets like massive distribution centers, optimizing shipping logistics, AWS (be the internet equivalent of utility companies), and Kindle (don't let anybody else cannibalize the paper book business). These were all being done with an eye toward massive future scale (e.g., at the time, many thought AWS was designed to use Amazon retail's excess server capacity, but it was the opposite... Amazon retail should fit in AWS' excess capacity).
Nobody expected all this from a "glorified book store" who "couldn't figure out how to turn a profit". But they were looking past the growing free cash flow and massive R&D investments in the financial statement, all unburdened by taxes.
----
(1) https://www.sec.gov/Archives/edgar/data/1018724/000119312505...