To understand when the government should use each of these kinds of fiscal policy, look at their names. The government should use expansionary fiscal policy when it wants the economy to expand. It should use contractionary fiscal policy when it wants the economy to contract (though it may actually want it to keep expanding, but at a slower rate).
We say that the government wants the economy to expand when we are in a recession. When we are in a recession, the economy is contracting. Real Gross Domestic Product (GDP) is dropping. This is not a desirable situation. Therefore, the government takes fiscal policies that are meant to increase aggregate demand and, thereby, to make the economy expand.
However, there are times when the economy is expanding too quickly. In such times, we tend to get demand-pull inflation. This is bad for the economy so the government will want the economy to expand less quickly. This is when it will use contractionary fiscal policies. These policies reduce aggregate demand. This causes the economy to cool off and stop expanding.
So, the government uses expansionary fiscal policy when there is not enough economic activity and contractionary policy when there is too much.