Vibrators contain an electric or battery powered motor that produces vibrations. When the power is turned on the vibrating motor is activated, creating vibrations.
Generally, battery powered vibrators tend to be less powerful than electric powered vibrators. Electric powered vibrators tend to be designed with stronger motors which use more power, which means you don't have to worry about electricity running out like batteries do.