Space (akash) came first. Air moved in space and became the air element. Air colliding with air creates friction and sparks, which is why fires start in storms, so air produced fire. Fire on cooling produces water: a metal lid or tawa held high over a wood fire soon collects dew-like drops. Water collected over ages turns into sedimentary (layered) rock through lithification, diagenesis and compaction, so water produced earth, and water also evaporates back into space, so the cycle repeats.
The Shiv Puran calls the elements the five mithun. Sequence to remember: Space, Air, Fire, Water, Earth.