It's a bit misleading to call them "undocumented opcodes". "Accidental opcodes" would be more accurate.
Instead of using microcode, the 6502 family used a programmable logic array as a lookup table to break an instruction down into a series of simpler steps. At each step of executing an instruction, the CPU would form a bit pattern from the instruction and instruction clock and feed it into the PLA. The PLA would then activate one of its output lines based on that bit pattern, and the CPU would execute the corresponding micro-operation. This process repeats until the instruction finishes and the instruction clock gets reset.
Many opcodes share micro-operations (for example, every branch instruction shares a "modify the program counter" micro-op), and the CPU designers took full advantage of this to reduce the size of the PLA. Because of this sharing of micro-operations, bit patterns that aren't a documented instruction can still trigger a sequence of micro-operations. The
JAM instruction (also documented as
HLT) is one where the sequence of accidentally-triggered micro-operations never resets the instruction clock.
Because the effects of these instructions are an accidental side-effect of the layout of the PLA, they can change from chip to chip as developers try to optimize things. The
KIL family are particularly vulnerable to changing because they require that none of the accidentally-triggered micro-operations include a "reset the instruction counter" step.
The vulnerability to changing is why
KIL would not be used in production code.
List of opcodes showing some of the model-to-model variation: http://bbc.nvg.org/doc/6502OpList.txt