For starters, undergraduate education [UG] in the UK is a bit different than what you have probably seen in North America, where 4-year liberal arts degrees are common. In the UK, undergraduate students choose 1 subject to study at university, which they study intensively for 3 years.
In the UK, law is a direct-entry 3-year UG that admits high schoolers directly. Medicine is also direct-entry but > 3 years.
Note that a US undergraduate degree is very different from a UK degree. The latter is much more specialized. In UK it is assumed that the general education occurs before the university level.
But in the US, the degree is quite general. Students of, say pre-law also study things like history, philosophy, foreign language, etc. It isn't that different from a History major. The "major subject" in the US accounts for half (more or less) of the total credits required. Even a math major will study all those things in the US.
To wit, why does UK UG already specialize, but not the US?