Disclaimer: Not my field but I'm doing my best.
We often measure the calories consumed indirectly by measuring the quantity of oxygen consumed. As we have a reserve of ATP(ATP is a molecule, a stock of ATP is some kind of battery of our body) in our body, at very short term the oxygen consumption is not necessarily perfectly correlated with energy use but at a longer term it works perfectly fine. Seek for further information on the Citric Acid Cycle to understand why the oxygen consumption is directly related to the energy created (which is itself at a long enough term directly related to energy use). If I am not mistaken a bunch of seconds should probably be a long enough term (time to consume all ATP at the start of an important effort) but I would appreciate if someone could give a reference for that.
For small animals we often put the animal in a chamber and calculate the energy consumption by measuring the volume of CO2 that they expire. For this purpose we have to measure the volume of CO2 at the entrance and at the exit (of the chamber) to measure the difference. For humans, we often put a mask on the face of the "cobaye". We allow him to breath normally without doing any effort for a while and then we ask him to run/bike/whatever on a home trainer.
I don't know much about such studies but it is important to 1) know the variance in energy consumption in the population for a typical exercice 2) understand that lab condition probably differ in various ways from person-to-person real life condition (no wind, no dust, stress of the experimentator, discomfort of the mask, ...).
As I have no idea concerning the variance in the population I cannot tell how representative are the summary values that we can find on many popular websites but I would tend to think that given the experimentation, these numbers has probably been fairly accurately measured.