Aquifers are relatively permeable zones of material that transmit water. Common aquifer materials include layers of unconsolidated sedimentary rock, like sands and gravels; and poorly cemented “bedrock” units like sandstone. Interconnected solution cavities in limestone, called karst, are common in some areas. Calling something an “aquifer” generally infers that the unit is capable of producing enough water via a well to be of interest to humans.
Aquifers are typically delineated using geologic and geophysical logs of boreholes from wells and test holes. These kinds of logs are typically required to be provided to a specified public agency for future use by others. Using these logs, a geologist can create cross sections of an area to evaluate the extent and thickness of these units. This is done keeping in mind the geometry of how these were originally deposited, such as linear streams, sheet-like sands, etc.
Surface geophysical techniques can also be used to assess subsurface conditions, but typically require “ground truth.” I remember asking a geophysicist what his data were telling him about an area, and he said, “I won’t know until you put some drill holes in.” It wasn’t as bad/funny as it seem. He could help color in between the data points, but first he needed to know what the specific geophysical response he was seeing meant as far as real rock present in the subsurface.
It should be rare to hit an aquifer zone unknowingly, as you described. It’s possible they hit a permeable fault zone, which can be tricky to know about beforehand. But I need to mention that engineers are notorious for keeping geologists out of the loop until a problem arises. They often don’t want to pay for upfront studies, the kind that geologists use to assess such things.