A modern engine burns most of the fuel, and that combustion yields CO2 and water (H2O). Gasoline (spark-ignition) combustion is fundamentally different than what goes on in a Diesel. Spark-ignition combustion is flame-front combustion, and Diesel is what is known as Diffusion combustion. In a gasoline engine, the fuel/air mixture that is next to the surfaces of the combustion chamber (a very thin layer) does not burn because the flame-front can not quite reach the metal walls. This is a phenomenon called quenching. This unburned fuel leaves the combustion chamber as Hydrocarbon emissions, which the catalytic converter does a very nice job of cleaning up. Gasoline engines produce very little soot, but a small amount is produced by any fuel droplets that don’t get completely mixed with air during the induction and compression strokes.
In a Diesel engine most of the fuel gets burned and exhausted as CO2 and H20, but many of the Diesel fuel droplets do not get completely consumed and they partially burn. The leftover from these droplets is soot. In a modern Diesel, very little fuel ends up close to the surfaces of the chamber, so quenching is not an issue.