On energy definition in electromagnetism: An analogy with viscoelasticity