The answer to why beer goes flat when it gets warm lies in the behavior of gases, and their solubility in water.
Most beers are dilute solutions of sugars, gases, organic acids, and other complex compounds, and, hopefully, alcohols.
The gas which gives fizzy drinks their distinctive fizz is carbon dioxide.
In the case of British-style real ales, the CO2 is generated by the action of yeasts on residual sugars in the drink, whereas in most beers, including British-made lagers, the conditioning gas is added artificially at the brewery or at the point of sale.
The problem arises because the solubility of CO2 is related to the temperature of the solvent in which it is dissolved, in this case the beer.
More gas can dissolve in cold beer than in warm beer. This is also why fish such as trout and salmon, which need a lot of oxygen, live in cold mountain streams and rivers, because the amount of oxygen dissolved in these environments is so much higher.
When the beer is served from the pump it will contain a certain concentration of dissolved CO2, but, as the drink heats up under the influence of a sweaty hand in a warm room, its ability to hold its CO2 in solution decreases.
This excess gas is then released into the atmosphere through the bubbles that you see rising in the beer, and the drink consequently goes flat. Other volatile compounds from the malt and the hops vaporize faster and you may notice that the beer also smells different.
The difference between lager and bitter is mainly caused by two factors.
The first is that lagers are generally served much colder than bitters, to disguise the fact that they have less taste, this is because they contain fewer fruity esters and longer-chain alcohols, as a result of the lower fermentation temperatures and different yeast strains that are employed in their manufacture.
The bigger temperature difference between the beer and the air means lagers warm up faster than bitters. Their rate of loss of CO2 is consequently much higher, and they go flat faster.
Secondly, lagers are generally more carbonated than bitters, so are fizzier at the point of purchase and therefore have more CO2 to lose in the first place. This extra carbonation, like the lower serving temperature, is usually used to camouflage the lack of flavor that is found in most British-brewed lagers.
The answer to the problem, of course, is to drink your beer faster, or sit in cooler pubs.