Mach number = TAS/ Local speed of sound (LSS)

LSS is proportional to the SQRT of the absolute temperature. Temp goes up LSS goes up. Temp down LSS goes down.

A shock wave is formed as a number of pressure waves come together this results in an increase in pressure and temperature, therefore the LSS increases in a shock wave. Shock waves reduce the velocity of airflow through them. So in respect to the mach number of an airflow it reduces through a shock wave. Through a normal shock the flow will always reduce to below Mach 1. In an oblique shock it will still be at mach 1 or above but lower than the mach no of the flow going into the shock wave

In an expansion wave, as the name suggest the air is expanding this reduces pressure and temperature and so LSS goes down. As the air expands it increases in velocity. So TAS goes up LSS goes down so Mach no increases.