This is a hard problem to diagnose. There are many things that can cause this, and trying to figure out which it is (or even if it's the same each time) can cause you to tear out your hair in frustration.
Even so, they all basically boil down to the bread rising too fast and then collapsing. (Sure. And all my money problems are caused by expenditures exceeding income. But how do I solve that? If I just stop paying my employees, I've really cut expenditures, but I won't have any income at all!)
One possible problem is too much liquid. The water turns to steam, puffing up the bread in the oven (or the bread machine), but then there isn't enough support structure underneath and it collapses.
Similarly, if there's too much yeast, or it grows too fast because of too much sugar, or too little salt (part of what the salt does is inhibit yeast growth), or if you were on timer and you didn't keep the yeast out of the liquid, or the temperature was too perfect, or who knows what, the little creatures just grow too fast and give off too much carbon dioxide, which puffs up the bread, but there isn't enough support structure underneath to support it, and it collapses.
It's somewhat interesting that the collapse happens early in the process in a bread machine (sunken top) and a little later in hand kneading and oven baking (mushroom top with huge air bubble). Or maybe that's just my experience.
One possibility is that your flour has absorbed moisture from the air. I now start all my bread recipes with 1/4 cup less liquid than the recipe calls for and find that I am equally likely to add flour or water to get to the right dough consistency. And after years of using a bread machine, I will say that it is far easier to judge the consistency of dough by feel (kneading) than by sight and sound (bread machine).
Edit: I forgot to mention: bread flour (high gluten content) really does make a difference. If a recipe calls for bread flour, use that. If it calls for all purpose flour, it may or may not really need it. (Sausage buns, dinner rolls, hamburger buns are all better [softer] with all purpose flour. All the recipes in Charel Scheele's book, Old World Breads [not a bread machine cookbook, but the recipes are easy to adapt], call for all purpose flour, but I haven't found any that seem to need it and only a few [holiday breads] that seem to prefer it.) I haven't yet found a recipe that required additional gluten if you're already using bread flour, although I've found quite a few that called for it. Maybe I've just been lucky and it's the difference of environment, or maybe the people who wrote those recipes are just health nuts. (Yes, I realize a nut is someone who forcefully expresses an opinion I don't wholeheartedly agree with.)