The example I will use is of a horizontally opposed pair of pistons in a cylinder with a fixed regenerator matrix. (The "regenerator matrix" is really just a fancy term for "heat store". It usually consists of a porous but dense metal that can hold heat temporarily.)
In the first image we have the pistons in the starting position. The Expansion Piston is hard up against the regenerator matrix and the Compression Piston is at the beginning of its compression stroke. Contained within the space between the two pistons is a "working fluid". In this case we will use Helium gas at 10 atmospheres of pressure.
To get the pistons moving we must supply a "heat differential". This mouthful really means that we must heat up one end of the cylinder and cool the other down. In this case we are cooling the right side and heating the left side.
As we absorb heat from the right side of the cylinder, and heat always flows from a hot to a cooler place, the working fluid is contracting - as all materials generally do when cooled. This forces the compression piston to move towards the regenerator matrix. In fact it literally "sucks" the piston towards the regenerator matrix.
The pistons are mechanically so connected that they run an "irregular cycle" so that as the compression piston reaches half way in its cylinder the expansion piston begins to move.
The piston are now moving in unison so that the gas contained between them is under constant pressure. As it is forced through the regenerator matrix, the matrix stores some of the heat from the gas within the matrix material.
When the compression piston reaches the regenerator matrix the expansion piston continues to move. We are heating this cylinder and heated gasses expand. The expansion piston is now being "pushed" by the expanding working fluid.
When the expansion piston reaches the end of its stroke it reverses direction and begins to move toward the regenerator matrix. At the same time the compression piston moves with it. This forces the working fluid, at constant pressure, through the regenerator matrix where it picks up some of the heat previously stored there.
The working fluid now fills the compression space of the cylinder where it will give up its heat to the cooling space surrounding the cylinder.
It becomes evident that so long as a temperature differential exists on the cylinder the Stirling engine must run!