Some new game changing battery/supercapacitor breakthrough might be just around the corner. If so, all that investment in the battery megafactory could get wiped out. Ditto with investing in lithium mining.
So the megafactory might be still happily minting money 25 years from now, or it might be nearly worthless 5 years from now. Presumably this means we'll be paying a risk premium on lithium and lithium batteries. It seems to me that it would be smart for Tesla to be investing in the very technologies that might disrupt their factory, as an insurance policy. That way, if the fortune you've invested in the factory evaporates, hopefully you'll have a new replacement fortune due to having a stake in the new technology. However, this strategy requires that you have the funds for this speculative investment, and has you encouraging the very research which will ruin your factory investment. (Also, maybe you won't have invested in the right places and won't have a stake in the new technology.) In the case of Tesla, they are major consumers as well as (soon to be) major manufacturers of batteries, so there is an additional up-side to investing in the hypothetical tech breakthrough.
Is lithium mining expanding fast enough to feed this factory when it comes online?