Library is usually much bigger, the trip to take a leak longer and more time-consuming, and the presence of other people much less physically dense. With a coffee shop there's a very, very narrow window of time in which someone can take your stuff, and it would be in full view of a much higher number of people per square meter than would be the case in a library. In many coffee shops, much of the customer floor space is within the field of vision of staff.
Oh, yeah, and fewer exits. The coffee shops I go to all have one exit, so if I want to go outside and grab a phone call, I just keep an eye on the exit. There's no other way anybody's leaving with my stuff.
So, while probability of theft may be higher in a coffee shop, it's rather harder to pull off, logistically.
I can't help imagining someone watching when you're off to take a leak, then walks to your stuff, packs it up and walks out. half a minute is probably enough to grab the most valuable item in sight.