There are layers of shale above and below the Madison limestone which keep the water confined so that it has to stay in the limestone. Shale, which was deposited originally as mud, makes a good barrier for underground water. Water can not flow through shale very easily, whereas the limestone contains interconnected holes in a large range of sizes. Water flows easily through the limestone. The Madison aquifer is the one in the middle.
Limestone is supposed to be a solid rock.
The limestone was originally deposited when sea shells or skeletal remains fell on the floor of a shallow sea. Most of the animals were one-celled animals living near the surface of the sea. The space between the shells, which is known as the pore space, contained seawater. However, during compaction and diagenesis most of the pore space was filled by calcite. Eventually the seafloor was uplifted, and the shoreline retreated.