Membrane keyboards use a soft conductive plastic, well, membrane-esque layer which upon key presses, sends a signal through a circuit to the computer.
Mechanical keyboards involve individual switches being used on each key, and actuation points based on different resistance weights on different keys.
They give tactile feedback, and are more responsive, hence why people use them for gaming and productivity.