Hairs of shaving brush cling together when it is removed from water due to
Surface tension
When the brush is taken out of water, the hairs cling together due to surface tension. This happens because the free surface of water tries to acquire a minimum surface area.