Secondary caves are formed after the surrounding rocks, when the forming of those rocks is already completed. The formation of the rock is the primary stage, the rock is formed without caves. The cave is formed in a secondary stage.
Most caves on the World are secondary caves. Maybe 90% of all caves are limestone Karst caves, which are secondary caves.
All secondary caves are formed by a mechanism which transports material away. The only posibility to mobilize rock is to make it liquid or gaseous so it can move away. There are only two mechanisms known to produce this effect: solution in water and (partial) melting.
Despite melting is theoretically possible, we found no cave of this type in literature. So all secondary caves are formed by solution of the rock in water.
The exact way, the rock is soluted depends on the chemistry of the rock and the water, on the temperature and maybe the pressure. Cave forming processes supported by high temperature are called thermal processes. Karst caves are formed by water with regular temperature using CO2 as agens. Several caves are formed by chemical and biochemical solution based on sulfur, often the sulfuric springs are warm or hot as they have geotheric origin.