The theory is air bubbles form in cooling magma. The rhyolite or other volcanic rock is porous enough to allow water to seep in and dry leaving a microscopic layer of silica which may or may not be colored by things like iron in the silica solution. The varying substances and silica layers give the beautiful striations. Conditions within the air bubble may allow quartz crystals to form which are macrocrystals or agate which are microcrystals. Other sediments could be formed around the layers then further agatization occurs. The cooling magma forms any way it can by heat, pressure, the air bubbles and sediments. Then, the softer material often called the matrix wears away by weather, temperature, pressure, erosion and the shape of the air bubble is revealed.
If you still have trouble visualizing this, think about the process of volcanic flows. Nothing can stop the flow. It burns and melts everything in its path. It flows around obstacles like rock formations forming eddies and such just like a river of water does, all the while cooling at different rates on the surface and the inside. In so doing it gets pushed by material and molten rock maybe flows over the cooling magma, great weight, heat and pressure. The formation takes time. The magma does not always keep the same orientation over eons. Earth shifting, water seeping in drying up at a different angle, the next layer forms, then an earthquake happens, another move.