First some background.
Glass and ceramics are stiff, but not totally rigid. Thin sheets are surprisingly flexible. To break a sheet of glass along a straight line, you scratch a line along the surface. You may wet the scratch, but cutting oil is often used. Then you bend the glass to pull apart the two sides of the scratch.
Once a crack is started, it is much easier to make the crack deeper and longer than it is to start the crack. The crack follows the scratch because there is an existing small crack that is easy to make bigger.
Stained glass artists often cut curves into glass. The same technique is used, but you have be be careful how you bend the glass. Bending tends to make a plane become a cylinder. The stress pulls the edges apart in a line. The crack may propagate along the line of stress, not the crack. It is possible to make the crack follow a gentle curve, but harder to make it follow a sharp curve. Working near the edge of glass may modify the cylindrical shape and allow sharper curves. Textured glass with varying thickness can be harder. Here is a video showing tools and techniques.
Is It Actually Possible To Cut Glass With Scissors Underwater? As the video Anna linked shows, water helps because it is a polar molecule. It exerts large forces at the end of the tip, helping it to grow. You may have noticed that a crack in a windshield might be stable until it rains.
You can do something similar without water. Loosely grip a corner of glass with a pair of pliers. Rotate the pliers to scrape one jaw over the edge of the glass. The rough face of the jaw hits local areas with enough pressure to fracture the glass. The angle nearly parallel to the edge keeps the stress from pointing to the center. The pliers pulls small pieces of glass out of the sheet.
Glass artists often do something similar with a diamond grinder or saw. This is always done in water. It is much more controllable that manual techniques.
Note that breaking glass is a good way to get cut. The videos offer some safety tips.
You may have seen a bullet hole in a window. A hammer blow to the same window might shatter the whole window. But the bullet leaves a cone shaped fracture.
A bullet hits hard enough that inertia becomes important. Glass in front of the bullet is fractured and pushed out of the way. Glass to the side begins to accelerate. But the fracture very quickly separates it from the shattering glass, leaving it unbroken.
A water jet works the same way. But the bullets are smaller and faster. This video explains a bit about them on the way to Six questionably legal pencil sharpeners. It is not the way I would go about it, but he makes more fun stuff than I do.
How does this apply to the cup? In air, the nail isn't a bullet. It puts a lot of pressure on a point, hard enough to make a scratch. Hard enough for the crack to propagate. But it also bends the bottom of the cup. The crack follows grows in a line out to the edge.
In water, two things are different. He hits the nail harder. And the water under the cup adds inertial forces that support the glass.
Update
I no longer think the explanation above is correct. It was based on the first video above.
Looking at videos 1 - 5, I see nails successfully being tapped relatively gently through glass underwater. I see nails being hit hard in air, and the cup still breaking. So inertial forces from hitting hard are not the full story.
Video 2 shows bubbles escaping when the hole is punched through. Inertial forces from being supported by water are not the full story.
One constant is that a hole is punched through the bottom of a cup. The sides of the cup form a strong rim. The bottom is not going to bend much. I doubt you could punch a hole in a flat sheet this way.
This Physics Girl video shows cavitation breaking glass. Fact-Checking this Viral Bottle Trick I doubt this is going on here, but it shows that unexpected things can happen.
Relevant - Why does diamond have lower tensile strength than Iron?
Bottom line - I don't know how it works.