Does riding on the sidewalk make it more likely to get a flat tire?
There's almost certainly more debris on the sidewalk.

Sidewalks are swept less often, and vehicle movement pushes debris off the travelled areas. You can more easily see the latter on wet days - there will be wheeltracks from motor vehicles with much wetter areas between. The worst areas are the edges of major roads, where debris gets pushed into the bike lane by passing motor vehicles.

On my ride to work the most puncture-prone area is where the bike path crosses a major road - there's a shield wall between the road and nearby houses and at the break in that wall is a small space for people to wait before crossing. That acts as a dust trap for all the stuff thrown up from the road and is rarely or never swept. It's common to see broken glass, sharp metal fragments and even nails in this spot.

I often carry a pair of secateurs and a small hand broom in my pannier so I can clear plants and debris from the bike path. It's a small amount of extra work but it helps a lot, especially on Monday mornings when the bike path often has broken alcohol bottles on it from the weekend.

Sidewalk cycling is also much more dangerous so should be minimised.