I've got personal experience with the driving thing, as a foreigner who drives. I've also got a Chinese spouse who drives, and went through the whole license process.
Foreigners who don't have a license back home have to follow the same procedure to get a license as Chinese folks.
Chinese people get a driver's license by passing 4 tests. The first one is the written test, the next two are practical road tests, and the final one is a written test about safety and manners. During the course of driving school you have to do a long distance drive too, usually to Chuxiong or Qujing or somesuch. The process is also rather expensive, between 4000-8000rmb, depending on the package you get. So it certainly isn't as if they're handing out driver's licenses like candy, or you just "sign up online" as suggested by the OP.
Mostly, road rules are not well-enforced (most penalties are by camera and there are apps that tell you where all the cameras are so you can avoid them very easily) and the penalties are not particularly expensive, which is why people drive like idiots. Back home if I speed I'm looking at a
fine of several hundred USD. Here 150 RMB is what most tickets will cost you. 10 tickets over the course of a year and you're only set back 1500 RMB, and anyone with a car can afford to pay that. There is a points system, but often points are not actually subtracted, because of course it is more profitable just to keep fining people, rather than revoking licenses left and right.
Another thing to bear in mind is that most Chinese drivers you see on the road are relatively new drivers, because China's car culture is only just now developing. When I first came here nearly 15 years ago, most people didn't have cars -- they were definitely luxury items. Now they're much more standard among the middle class. I learned to drive at 17, so I've been driving a good 20 years now, as have most people my age back home. Not counting taxi drivers, few drivers here have 20 years of experience driving. Give them another 10-20 years or so and I'm sure things won't be quite as bad.