An automotive airfoil (wing) is shaped like an upside-down airplane wing — it deflects airflow upward to generate down-force on the rear of the vehicle.
A spoiler is an obstruction to localized airflow that improves the overall airflow around a vehicle. Basically, you’re adding a barrier to a region of undesirable air behavior so the air will flow somewhere else.
For a more complete explanation, please visit our recent post A rear wing is not a spoiler.
An external detailed explanation can be found at this link.