To expand on this, the codes have changed a lot over time. London used to have separate codes for inner and outer London, which at their last iteration were 0171 and 0181. These were replaced in 2000 with (020)7 and (020)8 respectively. At this point it still made sense, if inaccurately, to group the first four numbers. There was also some perceived prestige with having an inner London number.
In 2005 (020)3 was included due to a shortage of numbers and (020)4 for the same reason in 2019. With the portability of numbers and the extra ranges it no longer makes sense to group the first four - and the number of people who want to infer location from a landline number is probably much lower these days anyway.