Why does potassium form peroxides but sodium does not?
If you look at the standard Gibbs free energies for the alkali metal peroxides, actually, lithium should form it most easily. The standard Gibbs free energies of formation are -564.8, -430.1, -418.4, -351.5, and -359.8 kJ/mol for $\rm Li_2O_2, Na_2O_2, K_2O_2, Rb_2O_2,$ and $\rm Cs_2O_2$, respectively.

If we're looking at reaction of an alkali metal with oxygen to form explosive compounds, perhaps we should look at superoxides. The superoxides are powerful oxidizing agents, and they can explode when mixed with water, acids, organics, or powdered graphite.

At room temperature, oxygen readily reacts with K, Rb, and Cs to form superoxides ($\rm MO_2$), while Li and Na don't. There is a direct correlation between superoxide stability and electropositivity of the metal concerned (source: Cotton &amp; Wilkinson's Advanced Inorganic Chemistry). $\rm NaO_2$ can be obtained by high pressure and temperature reaction of $\rm Na_2O_2$ with $\rm O_2$, and $\rm LiO_2$ won't form at room temperature.