Good question. I am still a new owner (just bought my 2020 XC40 this past May). One of the reasons I bought the XC40 was that it would fit inside of my garage. I think I have experienced what you are describing. When I first came home and pulled into my garage, I attempted to pull all the way in like I had with my previous car and the sensors picked up on objects at at the front of the garage and slammed on the brakes. I knew the items were there and have been there. I always knew how to slowly approach it and stop my vehicle within a few inches. This assured me of having plenty of room in the back for the garage door to come down and close without damaging my vehicle. I was not able to do that with the Volvo and had to rearrange a few things in the front of the garage to allow me to get closer. I assume there is something we can turn off to disable that front sensors when we do not want them on. Same as disabling the auto start/stop and folding in the sideview mirrors, etc. Will follow this topic to see if someone else figures this out. I solved the problem by cleaning up the garage, but can now see that it might be a problem in some other area where I don't have the option of removing things in the way. I wonder how this impacts parallel parking? I have not yet had to do that, but in many cases, it is a tight fit to get in a parallel parking spot, and you can easily be right up on the other vehicle in front or in the rear's bumper.
Your issue sounds like it is related to the Park Assist feature. Although I have never turned this off, doing so will probably solve your problem. That said, I have found that when I ease the car very slowly toward obstacles, I am warned, but the brakes are not applied. I actually have a railroad tie in the garage to stop my front wheels, leaving only about a foot between the front bumper and the wall.