Most people guess. They stand in the room, think "that's about two tins", and either end up with a half-full tin in the cupboard for ten years or a wall that is still patchy at 9 pm on a Sunday. A little arithmetic fixes both, and it takes about a minute.
The idea is simple: litres = paintable area × coats ÷ coverage. Paintable area is the wall area minus the bits you won't paint (doors, windows). Coverage is how many square metres one litre spreads over, which is printed on the tin. Typical matt emulsion is usually quoted at roughly 10–14 m² per litre for one coat, and a good rule of thumb is to plan on about 12. Tins vary, so always trust your own tin's label over ours.
The result above is a good starting point, not a promise. A few things change it in real rooms.
The wall underneath. Fresh plaster, bare filler and dark old colours all soak up or show through the new paint, so a fresh coat drinks more. A change from dark to light often needs a third coat, which is why the slider offers it. A primer or a thinned first coat helps on new plaster, so check the instructions on the tin.
The surface. Rough or textured walls take more paint per square metre than smooth ones. If your wall feels like fine sandpaper, move the coverage slider towards 9 or 10.
The colour. Deep, saturated colours often need more coats than pale ones, even when the tin says one coat is enough. Plan for two and be pleasantly surprised if one will do.
Ceilings and woodwork. These aren't in the number. A ceiling is length × width, and it is usually painted with its own ceiling paint. Skirting boards and door frames use a small separate tin.
Grab a tape measure and write down three things: the length and width of the room along the floor, and the height from floor to ceiling. Measure the ceiling height in two places, because older houses are not always level. For doors and windows, measure the actual openings if yours are unusually large (a patio door is much bigger than our default). Measure each wall separately if the room is not a plain rectangle, and add the numbers up.
If you rent, check your lease or ask your landlord before you start. Many landlords are fine with it, and some even supply the paint.
If you are painting a brand-new plastered room, a very dark wall, or a huge change of colour, buy more than the planner says. If you are only freshening a wall in nearly the same colour, one coat may do and you can plan a little less. When the number sits right on the edge of a tin size, think about whether you want the extra tin as a safe margin. Buying slightly more is cheaper than a second trip halfway through the job.