A kernel panic happens when the kernel detects an error from which it can't recover. A function named panic()
to handle this situation (often by dumping some debug info and/or rebooting the system) was first introduced in one of the very early UNIX versions, so that's where the name comes from (and it's still called that in most UNIX-like operating systems, including Mac OS X).
The famous Blue Screen Of Death (officially called a Fatal system error, as in VMS/OpenVMS) in Microsoft's NT kernel is also a form of "kernel panic".
A linux kernel error from which the kernel can (partially or temporarily) recover is called a kernel oops (you might see those in dmesg
output sometimes).
The reasons for a kernel panic can be a bug in the kernel (e.g. in a driver that is part of the kernel) or a hardware or software issue that causes an unexpected/unpredictable condition for the kernel (e.g. when it is impossible to start the init
proces, or it gets killed).
To find out what caused it you can see if anything was printed on the screen or to a serial console (if you configured one). If it is configured to do so you can also have the system make a linux kernel crash dump, which saves the kernel memory to disk in case of a panic, so that a kernel developer can analyze it (of course, that requires it to be able to write to a disk). In some cases /var/log/messages
might also have useful info (e.g. in some cases recovering from an oops may lead to an unrecoverable error later). There is some more detailed info here.