Why does the cabin air sometimes smell of kerosene? Why does the cabin air sometimes smell of jet fuel, although bleed air is tapped before it comes in contact with fuel ? How is this possible?

I have smelled this a couple of times in my life (twice extremely irritating), mostly during boarding/taxiing but at least once also during the flight (although in that case I don't remember if the smell was already present before take-off and merely lingered on).

Apparently a similar observation was reported in Q25405 but limited to the taxiing phase, whereas I witnessed the smell when the plane was still connected to the PBB (and also in-flight with the caveat above). The root cause may differ.



EDIT:
Meanwhile, I have found a satisfying answer on the net, but cannot add it anymore since the question is closed:


  « You’ll occasionally notice a strong odor when the plane is on the
  ground – a pungent smell similar to the exhaust from an old car or bus
  that fills the cabin shortly after pushback. Usually this happens when
  exhaust gases are drawn into the air conditioning packs during engine
  start. The wind is often to blame, causing air to backflow or blowing
  fumes through the pack inlets. It normally lasts only a minute or so,
  until the engine is running and stabilized. It’s unpleasant but little
  different from the fumes you occasionally breathe in your car while
  stuck in traffic. » (source)


(Notice that in my cases it lasted definitely much longer than "only a minute or so".)
You might have been smelling cooked turbo oil.  Leaking seals can potentially allow oil traces into the compressor bleed discharge, especially on auxiliary power units.  The other possibility is cooked deicing fluid, which is quite common.

Turbo oil and deicing fluid are the two major sources of petrochemical cabin stink.

Another possibility would be an APU with stalling/surging problems where there can be backflow into the compressor end of the motor from the burner can, which will admit burner can gasses into the air conditioning system.  If it is really kerosene you are smelling, that is the probable source.  

It could be coming from the main engine but there would likely have been audible rumbling or thumping sounds if it was stalling/surging while on main engine bleed.