These ballasts -- whether fluorescent ballasts or HID ballasts -- are used to provide the initial voltage to start a bulb and to limit the current passing through the bulb to prevent the lamp from breaking. The ballast's function uses some energy of its own, and this is called the ballast's loss factor, and should be considered along with the wattage of the lamps to know the total energy use of the system when the lights are on.
Importantly, you should realize that a ballast has specifications that need to be matched with the bulb(s) it will run. These specs are provided on the ballast itself, and we provide this kind of information on our ballast product pages when you need to make a purchase. (We're also available by phone to help you choose the right ballast.) There are even ballasts designed for specific applications, like Fulham IceHorse ballasts for refrigeration settings.
We thought we'd wrap up by sharing this video, which actually gives you a glimpse inside an old magnetic ballast and shares several details on the topic as well.