Also, setting up a good cycle lane can be more expensive than you think. If you have a nice bike lane that spreads over 5 km but there's a 200 meters gap in it because of a bridge which was too narrow to keep the bike path, then you don't have a nice lane at all.
Also, bicyclists in cities tend to travel closer to the speeds of cars than pedestrians, and tend to have more similar dynamics such as turning radius and stopping distance which infrastructure for cars is already designed around. Additionally, car drivers are licensed and there is an expectation of awareness that they must exhibit. This makes it far easier to place slower-moving "hazards" in their path than adding faster-moving vehicles in the path of pedestrians.
https://www.sallymorinlaw.com/bicycle-accidents/riding-your-...
Some areas have long stretches of sidewalk without intersections those are fine for cycling assuming they have little pedestrian traffic or are wide enough to pass safely.
I wouldn't want to bike when there are many cars in the same lane as me, but it is still safer than biking on sidewalks where are many pedestrians.
* It tends to be busy with pedestrians (not everywhere, as you mention)
* It's not safe when crossing side-roads
* It's inefficient if you walk at junctions
I have had more close calls with cars riding on at most 10 miles of sidewalk (and that's being generous to be honest) in the past decade than with ~6000mi riding in the road.
Also, the width and amount of obstructions on sidewalks varies widely.