Thanks to satellite imagery, we now know that both Mars and the moon also have lava tubes and skylights. These caves and holes likely formed the same way they do on Earth.
As a channel of molten lava flows, its top layer, exposed to air, cools and forms a crust. Below, the hotter lava continues to course until it empties out, leaving behind a tube-like cave. Skylights form when parts of the lava tube ceiling collapse. Sometimes these ceilings crumble and completely block access to the cave. Other times, they fall away clean, leaving pits with dangerous, potentially unstable overhangs. But once in a while, the rocks fall in such a way to give unfettered access to a lava-carved tunnel.