The problem is that we can't easily make gasoline with solar panels and water.
Making synthetic gasoline was already possible before WWII and that was used a lot by Germany.
It is true that making hydrogen is easier, because making gasoline requires additional steps and equipment, but due to the large disadvantages of storing and handling hydrogen, making gasoline is nonetheless preferable and it does not require any infrastructure change.
While hydrogen is preferred currently for room-temperature fuel cells, for the moment that seems like a dead end, because the current catalysts are much too expensive.
High-temperature fuel cells can use gasoline, so hydrogen no longer has advantages.
Even if one would not choose gasoline, there are still other much better ways to chemically store solar energy than hydrogen, e.g. ammonia or methanol.
For long-term storage, the battery auto-discharges, so the efficiency drops quickly with the storage time, until it becomes much less than for storing the energy by synthesizing some appropriate chemical compound.
For storing solar energy, both short-term storage (e.g. for a day or a week), like rechargeable batteries, and long-term storage (e.g. for a year or more), like synthetic gasoline, are needed.
Fun fact: methanol has a similar "invisible fire" risk, which is the origin of the "Don't let the invisible fire burn my friend" joke in Talladega Nights.