Minecraft wiki entry for Exploring_caves, associated text: Remember to always be aware of your surroundings in caves, especially upwards. One of the most common sources of mobs within previously explored caves is unnoticed openings in the ceiling or walls. If the player is in a ravine, watch out for monsters falling off of high ledges.
A good mining practice is to fully explore and light a cave system before beginning to mine out any resources. It is extremely dangerous to stop and mine in a dark cave, where you can lose your loot if killed. Check for "broken bridges" such as gravel masses or 2-block drops. If monsters can come out of them, you may want to change that; once safety is verified, you can save the blocked-off areas for later.
As part of exploration, "clean up" the area, taking off leftover blocks, filling small pits, and generally smoothing things out. In mineshafts, you can clear out most of the fence-and-plank "supports" as players "claim" an area. This will use a lot of axes, but it will improve both visibility and mobility, cutting down on unpleasant surprises. Notably, those fences provide better cover for creepers than they do for the player. This will also make it easier to tell where you are.
Water coming down from above is especially troublesome, as it can carry monsters down from a whole chain of darkened caverns.
It's a good idea to swim upwards and light the path of the flow.
Most water flows can be captured at the source with a bucket; if that doesn't work out, they can be contained with fences or blocks. Either way, be aware of areas where the water flow formerly blocked monsters. Some flows may be useful to keep for travel — the player can swim up or down waterfalls to traverse high cliffs, or land in water to avoid fall damage. With a little care, you can swim along the outside of the waterfall, which lets the player keep breathing normally.
Some water flows from cave ceilings come from openings in the seafloor. With care (and perhaps a door or some ladders), you can swim up these and mark the entrance with a jack-o-lantern, which will generally be visible from the sea surface. Such openings are also a quick way to get back to the surface if you've gotten lost. With a bit more effort, players can seal the opening altogether, perhaps leaving a shaft with ladders for their own use. (Ladders and signs can be used to block water.)
Lava flows and pools can also block the passage. Like water, lava flows can be bucketed if you can reach the source, or contained with blocks otherwise. Lava pools can be flooded with water to convert them to obsidian. Again, be aware of areas where monsters were blocked by the lava. Also, remember to re-light the area after removing that brightly glowing lava.
When fighting mobs, be careful of lava as mobs could knock you into it or you might walk into lava by accident and lose your items.