A likely scenario for how this could have happened is: the dog crawled under the sidewalk while it was still under construction and set up a den inside, and then the builders came back and finished the sidewalk while the dog was asleep, the dog would have been trapped inside like this.
It's impossible to know for sure unless there was a witness, of course.
We're just glad that someone noticed this pup and got her out in time!