I am part owner of a company that has produced Bear Resistant Containers for over 20 years. I have personally tested containers with Bears in captivity.
The basic problem is humans leaving food out unattended as well as not properly storing food. Black bears in particular are very intelligent and can see in color. They are nimble and can solve simple problems, like how to pop open a car door to get at bightly colored box which looks like something they previously discovered contained something edible. They have a very god sense of smell and even if they can't see food they can smell it out and find it.
The basic rules are simple:
Never prepare, eat or bring food into a tent or tent trailer.
Do all of your cooking away from where you sleep.
Do not leave any food out and unattended.
Put all food away as soon as you are finished with your snacks and meals.
Do not leave food in your vehicle. (an exception may be the trunk or a camper) In several places, notably Yosemite, Black Bears have figured out that ice chests contain food so if they can see an ice chest or anything that looks like it in a vehicle there is a good chance they will break into the vehicle).
Kepp your campsite clean and minimize odors. Tightly reseal packages.
Use the Bear resistant storage lockers if they are available.
Note: When Bears break into a vehicle (or dwelling or whatever) they not only cause a lot of physical damage they also frequently drop smelly reminders of their visit.