Head gaskets that I've worked with have a number of features to compensate for slight surface imperfections and/or distortion.
- A "fire ring" stamped into the gasket material around the periphery of the cylinder. When clamped, the flattening action pushes the metal around a little, which should preload the gasket material against both surfaces a little more in that area, which is where the highest forces occur (due to cylinder pressure).
- The gaskets are coated with a soft material that is intended to fill the voids and surface imperfections (e.g. machining marks) in the mating surfaces.
- In some cases - Multi-layer gaskets accommodate for more distortion by doing both of the above several times over (in each layer of the gasket). If for some reason the head moves around differently from the block due to differing thermal expansion, the discrepancy is spread out over a few gasket layers instead of having to be fully accommodated over two surfaces (the top and bottom of the head gasket).
In addition, the features of the engine itself contribute.
I'm going by memory but I think the last motorcycle engine that I put together uses four 8mm studs around each cylinder which is 58mm bore. If the peak cylinder pressure is 100 bar (which is an educated guess) that's 26 kN of force (something over 5000 lbs, if you wish) trying to push the head up, and each bolt (assuming grade 10.9 - the recommended torque is about right for that) has a clamping load in that range - so it has 4 times more clamping load total between the 4 bolts that surround that cylinder. On that engine the studs extend well up through the head with nuts applied at the very top ... spreads out the clamping load better.
On those engines both the block and the head are aluminum ... same thermal expansion rate. Same coolant circulates through both. The holes in the head gasket are used to regulate the coolant flow distribution, and I'm sure someone has been playing with simulations in order to make sure the coolant flow distribution is right.