If energy is formed by a generator, how does the generator form the energy?
Okay, if we get technical, energy is not formed by a generator. Actually, a generator CONVERTS energy from one form to another and it often uses several conversions. I assume you are asking about an electrical generator. There are many types of devices that generate lots of different things that we call generators. Let's stick to electrical generators though. A coal fired generator is probably the most common.
Coal stores chemical energy that originates mostly from the sun. Coal is made of things that lived thousands of years ago (mostly plants) that lived, died, rotted and were covered by more plants that lived, died and rotted. Eventually, under a lot of pressure from other dead plants lying on top of them, plants slowly turn into coal. In this transformation, coal keeps the energy it stores from its life in the sun. We end up burning some of the earth's coal, which releases chemical energy and converts to thermal energy (heat). The thermal energy boils water into steam. Steam turns into mechanical energy that we use to turn turbines. Turbines spin magnets through coils of wire and force electrons to move. When the electrons in the wire moves we can then call this electrical energy.
Each conversion is not 100% efficient though. A little energy is "lost" during each conversion, like when steam leaks away from boiling water. The energy is never really "lost," but we still cannot capture all of it. Some energy conversions are more inefficient than others. Batteries are one example of a very inefficient energy conversion. We put more energy into a battery than we get back out. This loss is one of the reasons electric cars are not such a great idea, although hybrid cars are. So, getting back to your original question, energy is not formed by a generator, so maybe we'd be better off calling them "convertors."
The sun is the primary energy source for life on earth.
Brian Kross, Chief Detector Engineer (Other answers by Brian Kross)