In case of 4.4 KitKat it was the idea of Nestle's advertising agency, J. Walter Thompson [0]. It was novel at the time, and it as more than just jumping on the letter "K", because it tied the "have a break, have a kitkat" line with the idea that people reach for their smartphones when they have a break. Now I imagine it's just people in suits negotiating the deal for the next release name.
[0] https://jwt.co.uk/work/android
Disclosure: I have worked for a JWT subsidiary at the time.