Although diesel and petroleum have different densities, they can be mixed, although doing so is not advised. Both fuels do not evaporate at the same rate, and due to their different burn characteristics, they are likely to cause problems if used in an engine not designed for the mixture.
Gasoline is a volatile fuel, and gasoline engines rely on a spark plug to ignite the fuel. Diesel fuel is more stable but has a high flash point, and diesel engines rely on compression to ignite the fuel. If diesel fuel is put in a gasoline engine, the spark plug has trouble firing the fuel since diesel does not evaporate well, and the engine either does not run or runs badly without much damage. Since gasoline is formulated to prevent auto ignition, which a diesel engine requires, if it is put in a diesel engine, it either does not ignite or it does so uncontrollably and causes severe damage.