Why is the capacitor considered lossless, even if it can store/give out energy?
Dissipation of energy means transforming it to a form less usable and not easily recoverable to the original one (usually heat).

With capacitor, it is obviously not the case - an ideal capacitor maintains constant voltage on its ends until you discharge it by connecting external load. It provides you exactly with the amount of energy you have given it, equal to the expression you wrote. Resistor, for example, "consumes" power as well, but when you disconnect it from the source, it has zero voltage across. Here, the energy has been dissipated into heat and you cannot recover it by any means.

Real capacitor, though, has some parallel leakage conductance preventing it to stay charged forever. When using it in an AC circuit, dynamic losses in the dielectric dissipate some power as well, this is quantified by Dissipation factor, \$\tan \&gt; \delta\$.