When we stayed in Bologna for a month, we were told that it was used defensively. You can see a very long ways from the top of the central tower (I think it’s closed at the moment). It would have been nearly impossible for an army to approach Bologna without several days for Bologna to prepare