Why does the J58 engine of the SR-71 have a diffuser after the inlet spike?
Generally, a compressor cannot work efficiently at supersonic speed due to the shockwaves, the role of the inlet cone and diffuser is to slow the air below Mach 1. There is a similar need for a ramjet, so that the combustion can occur within the engine and produce thrust.

The cone position and diffuser geometry are adjusted according to the airspeed. The overall shape of the diffuser is diverging.

From Bernoulli's principle, the diffuser decreases velocity and increases pressure according to:

$\frac 1 \rho \; dp = - \mathrm V\;d \mathrm V$ where $\rho$ is air density.

Look at this video: Converging Diverging Nozzles for more details about how pressure and velocity are affected in a nozzle / a diffuser. Here is a summary:

  

The J58 is turbojet within a ramjet. The forward section of the engine has a complex role. It adapts to a large range of speed (0 to Mach 3.2) and altitude (0 to 85,000 ft), and modifies the airflow to work either as turbojet, or as a ramjet, depending on the airspeed.


Simplified adjustment of the airflow (source).

Actual mechanism used at different airspeed ranges in the J58:

(Source)