Why do vegetables cooked with freshly ground spices taste better than those cooked with powdered spices available in the market?
Many of the chemicals in food responsible for how a it tastes are also the same ones which, as they escape into the air, give it it's smell.

These oils and aromatic compounds which give many spices their flavour break down or escape over time changeing the taste as they degrade.

Some spices stay fresh for a long time once ground, others are well worth (as you are finding) doing your self.

Many of these compounds react with the oxygen in air to become new ones, these would then potentialy taste stale. Other compounds may break down if light gets to them; especially natural light as ultraviolet breaks many chemicals down. Other chemicals just evaporate away.   

All of these reactions depend on surface area... so the smaller the bits of spice the faster they lose the flavor/smell chemicals.

Very fresh powdered spices wouldn't have this issue. Also if you ground the spices yourself and then left them for a few week/months you would find much of the taste has gone from the powder.