Dear Student,
Potassium and Sodium are very reactive alkali metals.
They react with water vapours in air to form their hydroxides and evolve hydrogen.
2Na + 2H2O --------------> 2NaOH + H2
2K + 2H2O --------------> 2KOH + H2
The reaction is so exothermic that evolved hydrogen catches fire.
So, to prevent their contact with water vapours, these are kept under kerosene.
Regards