What happened?
It's very simple, you have intuitively added pieces of fresh and raw fruit which contain a lot of water. During the baking process, this water was transformed into steam by the heat, and this steam, which can't get out, pushed the not yet baked dough, therefore soft, around each piece of fruit, and formed this hollow that the bakers call "cavern". Once the dough is cooked, the cavern remains in place, even when cooling, and therefore gives this unsightly aspect.
It happens as soon as you add something containing water to a dough, and it is much more pronounced when it is a leavened dough (brioche, bread, because of or thanks to the gluten network) or flaky dough, and much less on travel cakes (cake, cookies, ...) easier to steam through.
This also applies to salted food for example for a sausage in brioche you would have the same problem.
How to avoid this?
There are basically 2 solutions: Either you remove/reduce the water in the first place, or you do something to allow the cooking steam to escape.
Removing the water, or at least reducing it is quite simple, for fresh fruit for example we cook them slightly before. For example for apples and pears, in a little butter and sugar, you can even caramelize them, which gives a whole new (delicious) taste to your cake.
For a sausage, same treatment, either you cook it in the oven, or you poach it before incorporating it.
This is the secret of very aesthetic brioche sausages.
For a galette des rois for example, it is about 2 discs of puff pastry with cream in the middle, we pierce a small hole, the chimney in the center of the galette to allow the steam to escape. Without this chimney you will have in the oven a kind of huge puff pastry bell, and full of emptiness.
It should be noted that for all this, we are more on a question of aesthetics and mouthfeel, the taste is not impacted.
In summary: To avoid cavities in your cakes, reduce the water brought by your inserts, or provide an outlet for the steam generated during baking.