Energy is a feature that can be used to perform all sorts of gathering actions, done in fishing, mining, herbalist and woodcutting. It is not mandatory to have energy to gather, but recommended to have it if possible.
You can gain energy through a handful of ways, one of which is by simply staying online. Every 30 minutes you will receive 20 energy, which you can see right below your mana and health bars, like this: . You can also obtain energy by completing quests and daily quests (while off cooldown), in which the amount will vary depending on the quest level, the higher the level, the more energy it will give. Any gathering action in any profession will consume 5 energy.
While possible to harvest several different nodes without energy, it is advisable to gather while having energy, since it provides a 50% bonus on top of collected materials, while having no energy will result in -50% penalty instead.