USB B connectors are used on devices which receive power like most peripheral devices.
In the standard USB B connectors specified in the four pins are defined. Two pins are used for power and two pins are used for differential data transmission. If you look carefully at the connector you will see that the pins for the power connection (pin 1 and 4) are slightly longer. This is done on purpose to first connect the power supply when connecting a USB device, and only afterwards establish the data connection. With this sequence the chance that the driver or receiver ports of the data connection receive awkward and possible dangerous voltages is lowered substantially.