Bananas can turn black due to over-ripening or due to melanins that are released if the banana is cut, bruised or damaged in another way. Melanins are brown pigments that are created when the enzymes released due to the damage react with the air.
Just like many other fruits, bananas ripen over time and change color and composition. Bananas start green, but due to the production of ethylene gas, they ripen into a yellow, softer form. If bananas are left for too long, they will continue to ripen and the yellow peel will be broken down, which produces a peel that eventually turns black.