The stress element must satisfy equilibrium; therefore, we will write an equilibrium equation for the sum of moments about B.

Derivation of shear stress formula