There's usually a couple of "dolphins" (the channel equivalent of pierside "fenders" in a way, you could say) on either side of the channel to funnel ships through and under bridges, however there's only so much that can be engineered to protect the pilings before you start encroaching into the shipping channel. Most people have never seen nor, do they understand the size of modern container vessels, A PANAMAX sized ship is going to destroy whatever gets in front of it, even a glancing blow is catastrophic.
Another thing to remember too is that many bridges were built long before cargo ships became as large as they have. In the case of the Dali in Baltimore, the Dali is TWICE as long as cargo ships were when that Baltimore bridge was built.
And here is a nautical chart showing placement of the "dolphins" around the bridge in Baltimore. May have been good protection way back when, but surely needed to to be upgraded as ships became larger ...