Cave ins work in a similar fashion to minesweeper. Unstable tiles are randomly seeded throughout the caves, and mining into one will always cause a cave in. The game warns you if an unstable tile is nearby by displaying dust particles floating from the ceiling when you knock out an adjacent tile.
It's a little hard to convey in a static picture, but you get the idea. Now, this dust means one of the 8 tiles surrounding it is marked as unstable. When you're wall prospecting you don't get any warning and can mine straight into these unstable tiles causing a collapse. But when you're mining and/or making tunnels you can start to figure things out. Here's an example of an area I was clearing with coal. Any place you see a coal pile, there was dust from the ceiling. I screwed up and caused a collapse, that's marked by the bat hide.
And unfortunately, science demands sacrifice. I mined out the furthest right unstable tile that I'd marked, and got the painful but expected result.
And there you have it. If you'd prefer to dig support free, assuming there's not too many unstable tiles and you're careful you're more than able to do so if you choose.