In an Otto or Diesel engine, the concave head of the piston forms one wall of an expansion chamber inside the cylinder. The opposite wall, called the cylinder head, contains inlet and exhaust valves for gases.
As the piston moves inside the cylinder, it transforms the energy from the expansion of a burning gas (usually a mixture of petrol or diesel and air) into mechanical power (in the form of a reciprocating linear motion). From there the power is conveyed through a connecting-rod to a crankshaft, which transforms it into a rotary motion, which usually drives a gearbox.
A steam engine is another type of piston engine. Here, the piston is flat on both sides, not concave, and both sides of the cylinder are alternately filled with steam.