A by-product is something that you produce while making something else. What do Amazon and Google make that produces storage?
A by-product is formally defined as "'output from a joint production process that is minor in quantity and/or net realizable value when compared to the main products". The search and retail services that Google and Amazon respectively provide require a lot of computers and these computers invariably have an excess of hard drive capacity even if they are using storage area networks or similar. (storage is purchased as a step function so there always is some amount of excess capacity even if very small) This means that their primary product (search and retail) generates storage as a by-product. Offering storage related services is a way to recapture some of the value of this excess storage which would otherwise merely be a cost.
Do you mean to say that they need massive amounts of storage in the first place? That doesn't mean it's free.
Nobody said it was free and by-products aren't free either though they can be very very cheap sometimes. They simply aren't as valuable in the marketplace as the primary product. From an accounting standpoint it is a sunk cost - the money has already been spent for a separate purpose and any (rational) decision making about what to do with the asset going forward should not factor into the equation.
Excess capacity for any company on any product can be normally be sold very cheaply. This is how foreign companies can sometimes sell products for what seems like ludicrously low prices even without government subsidies and why accusations of dumping are hard to prove. Once the fixed costs of the product have been recovered, anything the company can sell it for after that is pure profit. They basically can sell it for as low as their variable cost without losing money. Google's variable cost on a unit of data storage is extremely low - probably no more than a few cents per megabyte if not less. It's not free but it's pretty close. A great example of excess capacity with a low cost is text messaging for cell phones. The cost to AT&T to send you a text message is very very very low because the mechanism to send the message simply rides on some gear that has to be there anyway for a separate purpose. Once the decision to put the cell tower in is made, text messages are almost pure profit even though technically they could be considered a by-product. (now their market value is high enough that by-product might not be an accurate description anymore though...)
It may well be that Google and Amazon can maintain storage cheaper than most people, because they do have a lot of it. Google, for example, has put a great deal of research into how to have tremendous amounts of mass storage as inexpensively as possible.
I'm a cost accountant and what you said here is 100% correct. They are able to achieve economies of scale that few others can match.
That takes advantage of economies of scale, and has nothing to do with by-products.
You are conflating two accounting issues that are properly separate. Google gets storage very cheaply on a per-megabyte basis because they buy huge amounts of it and have cost effective infrastructure to make use of it. They end up with large excess amounts of it because of the nature of their primary business (not data storage) which effectively makes it a by-product to Google. From an accounting standpoint this is no different than how oil refineries generate natural gas as a by-product when refining oil into gasoline. They would have to have the storage whether or not they went into the data storage business. By going into the data storage business they are attempting to get market value for that by-product rather than simply writing it down as waste. Either way that excess capacity is a by-product. Calling Google's excess data storage capacity a by-product is logically correct.