Thankfully the overwhelming majority of Black Bears want nothing to do with humans and will scurry off quick fast once they sense you in their midst. That bear that ran up the tree was a cub and was probably too young to really assess the situation and not run into human presence, plus youthful curiosity and all that good sh1t. Of course if you know one ran away from you, please go in the opposite direction, even the most timid animal goes from defense to offense quickly once it feels too encroached upon.
Now if you come across a rabid one or get between a mom and her cubs? Yeah you better have some bear spray on you and you better know how to access and use it quickly, or else
And notice I said bear spray and not a gun. You get a much wider attack zone with a mist than you would a bullet and burning eyes are a lot harder for a bear to fight through than a bullet from a pistol that it can eat and keep fighing through, even if you hit a vital organ that will eventually kill it.
Overall though, a black bear attack is on your list of of small concerns while exploring in the woods. Brown bears (Grizzy, Kodiak) aren't retreaters and will wreck you off GP, but won't actively seek out a fight with a human. Polar Bears will straight up stalk and hunt humans and are always on the offensive, fukk a cute Coca-Cola Christmas commercial.