The pressure comes from the street, and the pipe keeps what is already in it
Water in a house is not stored under pressure; it is pushed. The mains holds it at a few bar, and the moment you break the connection to the mains, that pressure is gone — the water in the pipe is now just water, sitting in a tube with two ends. Which is exactly why a closed valve does not stop a leak immediately. A ten-metre run of 20 mm pipe holds about three litres, and that three litres still has somewhere to go: out of the hole. Closing the valve stops the supply; opening the lowest tap in the house lets air in at the top so the rest can run out at the bottom. Two different jobs, and the second one is the step people skip.
The other thing worth knowing before you start is which way a valve closes, because it is not a screw thread and it is not “until it will not turn”. Most household main valves and almost all the small ones under basins are ball valves, and a ball valve tells you its position with its handle: along the pipe is open, across the pipe is closed, a quarter turn apart. Older mains stopcocks are gate valves and take several turns of a round wheel. Both close clockwise. What you must not do is put a bar on a stiff old handle and lean on it: a snapped spindle turns "will not close" into "will not close and is now spraying".
There is a free confirmation available at the meter. With the main valve closed and every tap shut, the small red dial or the last digit on the meter should be still. If it is creeping, either you closed the wrong valve, or there is a second supply — a garden tap fed before the stopcock, a second bathroom on its own branch. That check takes ten seconds and it is the difference between draining a pipe and standing in a puddle wondering why.
Three situations, three answers
Water out of a wall, a ceiling or the floor is the main valve, and nothing else. Find it — under the kitchen sink, in a downstairs cloakroom, next to the meter, or in the pavement box outside — turn it clockwise until it stops, then open the lowest tap in the house and let the pipe empty. Put a bucket under the leak if you can, and if the water is anywhere near a ceiling light, switch that lighting circuit off at the consumer unit instead of reaching up into it.
A hose or a joint spraying does not need the whole flat turned off. Every appliance has its own isolation: the small oval handle under the basin, behind the toilet, behind the washing machine. Close that one, wrap a towel round the joint, put a basin underneath, and only then think about the part. The repair is usually a washer or a flexible hose, and it is a different page — but the first move is the same, and it is free.
On the hot side the order changes, and this is the one that burns people. Put the heat out first — the boiler or the immersion off at the switch, the gas boiler's own valve closed — then close the cold feed to the cylinder or the heater, then drain, keeping your hands out of the flow until it runs cold. A cylinder full of water at 65 °C does not need to be under pressure to give you a serious scald, and a heating system that runs dry while the burner is still lit is a separate and expensive failure.