1: Just create an area directly adjacent to an existing megacity where there is no law. Then the economics of drugs and no planning regs will do the rest.
This is how kowloon came to be. The area was technically under the jurisdiction of mainland China, but China had zero desire to police it and the UK could not police it as it was not under their jurisdiction. As a lawless mini state it became self-managing.
2: For environmental reasons make it illegal to build outside existing urban areas and then consider the possibility that the climate emergency will make Africa, central India, western China, and the southern US uninhabitable. The massive wave of immigration could result in a 2-4x population increase in the still habitable areas.
3: 2 is still not even close to enough, so we also need uncontrolled birth rates. The problem is always going to be that no current government would sit back and do nothing whilst witnessing a population explosion against the backdrop of climate emergency and no more space, so there needs to be a very compelling reason to still increase the birth rate. How about a virus which we think is going to kill 98% of the population in ten years but turns out to be harmless?
Then there is the matter of how - we need to make the malthusian catastrophe happen, so we need to remove a lot of the features of modern life which prevent it from happening.
- No birth control
- No TV
- Stop teaching responsible parenting
- No TV
- Free houses for everyone
- No TV
- Polygamy encouraged
- Early marriages encouraged
- Having > 5 children gives you a lifetime income and you never have to work again.
Environmental pressure and massively increased birthrate is likely to be the key driver, but you need to get that birth rate up up up! In order for just London to have the correct density you will need 3,030,000,000. That's nearly half the world's current population in just London!
Edit: Assuming other cities have the same ratio of population:area, that would make for a total global population of 2.4 trillion
Not to mention feeding them all, but you would at that point probably need to have people hooked up to cybernetic implants which convert solar energy directly into glucose and trace minerals - there is absolutely no way in hell that the planet can sustain that many people using any currently known or theoretically plausible agriculture method.
In fact, transhumanist tech might be the initiator of the second population boom - it bypasses the aforementioned malthusian disaster and allows once again for unchecked population growth. So I'll make that my 4: Transhumanist revolution.