When the air-gasoline mixture burns normally, the flame front proceeds at a certain rate, and there is no knock. With high enough temperature and pressure, a shock wave is produced and the flame front is on that shock wave: knock. It's the difference between fire and explosion.
Delaying (retarding) the spark allows ignition to occur later than the compression-caused peak temperature and pressure, potentially preventing or reducing the shock wave. That's the physics.
Granted, Diesel engines have no spark plugs and effectively run in a knock condition at all times; that's why they have to be built to be more sturdy.
There are a number of types of fuel injection. Direct injection is used mostly by Diesels; the fuel is squirted into the cylinder long after the intake valve closes. Throttle-body injection and port injection (known by many names) vaporize fuel into the air before the intake valve closes. Stratified charge injection usually utilizes direct injection.