But can't you ride a bike on the sidewalk?

No. In most places, it is illegal. Besides, it is also dangerous.

Resources

Road Cycling: Why Do You Ride Like That? - CyclingSavvy

https://cyclingsavvy.org/road-cycling

It has the same style like mine where it answers questions.

6 Things You Need To Know About Cycling On The Sidewalk : NPR

https://www.npr.org/2016/10/16/496865680/6-things-you-need-to-know-about-cycling-on-the-sidewalk

Bicyclists feel safer, but pedestrians feel endangered.

Riding on a sidewalk doesn’t remove the threat of crashing into a car. Rather, sidewalks make bicyclists invisible to motorists who don’t expect to see them at driveways and crosswalks.