Therefore, your statement "only dividends matter" must be incorrect since Amazon stock has a non-zero value.
Whether or not the company has paid out dividends in the past is a good predictor of whether they'll do so in the future, but it's not the only such predictor. Having accumulated a mountain of cash but using it to invest in the business (buildings, equipment, and other productive assets) is another. Probably better, at least in some sense/cases.
The other way in which the stock is supported is by other people's expectations of other people's expectations of future dividends, and so on. I.e., speculation. Still tied to dividends, just in an unhealthy and volatile way.
I would make a large bet that Amazon will announce a share buyback and/or dividend in the next 5 years.
That of course means that it's not actually a law of economics, the way it's always presented. And I must confess myself reluctant to believe this is a permanent situation.
But if there is no expectation that shareholders will actually receive any of the future cash flows, then there are zero future cash flows to discount.
84 companies in the S&P 500 index do not pay dividends.