RP-1 can be simplistically thought of as a mixture of hydrocarbon chains with an average carbon chain length of 12 and an average of 26 hydrogen.

In idealized stoichiometric combustion with oxygen, the products are only CO2 and H2O. In real world combustion, particularly with inadequate oxygen, the carbon chains can combine into large molecules composed mainly of carbon.

https://www.ariyancorp.com/petroleum-coke-petcoke
As airborne particles, this is known as soot. As a solid, it is coke.
A stoichiometric mixture of RP-1 and oxygen can burn at 3801C which is significantly above the melting point of stainless steel (1530C). This temperature would consume the preburner turbines for rocket propellant pumps. As a result, preburners are run deliberately oxygen-rich or fuel-rich. Fuel-rich preburners produce very sooty exhaust, as seen in this Merlin test fire:

Fuel-rich conditions inside an engine can deposit coke as seen in this jet engine fuel nozzle:

Credit: NASA https://www.omnia.ie/index.php?navigation_function=1&navigation_collection=National+Archives+at+College+Park+-+Still+Pictures&repid=2
The conversion of kerosene to coke can occur outside combustion chambers any time it is heated above the coking limit of about 300C. This can happen when fuel is in contact with hot engine parts, particularly during shut-down when cooling flow ceases and latent heat remains.
Coking is particularly a problem in passages used for fuel cooling of combustion chambers. Coke deposits can also change clearances between mechanical parts.
Fuel coking was a significant risk for the SR-71 since the fuel was used as airframe coolant and engine lubricant. It was heated to 270C before being burned as fuel. The SR-70 burned JP-7 to counter the potential coking problem. https://en.wikipedia.org/wiki/JP-7
Exxon has a .pdf primer on coking at https://www.exxonmobil.com/en/aviation/knowledge-library/resources/engine-oil-coking