Building structures underwater requires some interesting engineering.

Have you ever looked at a large bridge or other structure whose foundation was rooted underwater and wondered how engineers ever went about constructing it or will ever fix it? When construction needs to take place somewhere that is submerged underwater, engineers use a series of large driven piles into the waterbed called cofferdams to create a dry workplace.
The way cofferdams are built:
In terms of geotechnical engineering, the process isn't as simple as just pushing walls into the ground, engineers have to carefully design the structure to not flood and keep the workers inside safe from collapse. Most traditionally you would see cofferdams in the construction process of support piers for bridges, but they can be used in a wide variety of aqueous engineering
The piles of a cofferdam are driven into the earth in whatever formation necessary to a specific depth. When water is on one side of a wall and water is pumped out of the other side of the wall, this creates a hydraulically unstable system which can cause water to seep up through the ground.
Without getting too complex into the geotechnical engineering of this hydraulic phenomenon, there is a depth at which a wall can be driven into the ground that will keep water from seeping to the other side of the wall – typically defined by soil type and water table. The piles used in cofferdams are usually driven into the surface at a minimum of this calculated height in order to keep water out.
Removing the water from the structure:
Once the entire cofferdam is in place, pumps are used to extract the water interior to the dam structure, ultimately creating a dry workspace. Sometimes, getting the piles that make up the cofferdam to a necessary depth on the lake/ocean/river floor is simply too expensive or impractical. In cases like this, a series of pumps are set in place to constantly pump out excess water as it seeps into the cofferdam structure.
These structures are used very commonly when constructing dams, piers for bridges or other forms of aquatic engineering. While it may seem that having such a large work area under the surrounding water level may be dangerous, and it is, it's not as dangerous as you may think. Work inside of cofferdams is usually only allowed under the most pristine conditions when the water is generally static. In these states, failure modes of the pile dam are slow and predictable in nature. To help fight against these slow failures as well, a series of primary or backup pumps can kick into overdrive to help keep the inside of the cofferdam dry until crews can evacuate.
When ships need to be repaired, engineers will also use cofferdams as a sort of dry-dock to isolate the ship from the water and repair it where it sits. This is typically done on larger ships where it would otherwise be impossible to lift the ship out of the water. So, for example, when a cruise ship is lengthened or expanded, engineers will construct a cofferdam around the ship and pump out the water, allowing for workers to have a dry work area. It is important to note that cofferdams are not cheap, but for the projects where they are used, they are the only construction option.
History of cofferdams:
Cofferdams are rather old when it comes to underwater construction vice that there aren't really any other ways to build underwater. The origins of these structures date back to the Persian Empire where they began as earth cofferdams.
These early structures were made essentially how you might think, with earthen walls being built up, the water being bucketed out, the structure being built, then the earth walls removed. It was rather tedious, dangerous and time-consuming, but it did the trick.
The next innovation in cofferdam engineering was made by the Romans. Roman engineers used woodpiles that they drove into waterbeds to wall off underwater areas. This was particularly an impressive feat considering the function was similar to modern steel cofferdams, yet the Romans were able to accomplish it with wooden supports.
In what seems like a step back in the engineering of cofferdams, the next innovation was to move to sandbags, which didn't occur until the late 19th century. During the Napoleonic wars, people began using sandbags to control water. The bags were initially used to protect troops but eventually began being used to control the water by building quick dams. While not the traditional use of cofferdams, these early sandbag dams allowed for troop movements while also offering the added benefit of protection from gunfire.
Steel sheet pile cofferdams:
Finally, after the long history of cofferdams in construction, in the early 1900s, steel cofferdams were first invented by a German engineer. These first steel dams utilized interlocking U shaped steep to control the water flow and are much like what we still see in use today. This was really the final major innovation in the history of Cofferdams as today, we just see minor proprietary changes in the wall interlocking technology.