Why do some LEDs flicker when dimmed or turned off?

FAQ
This is usually due to incompatibility between the driver and the control system. When purchasing an LED product, it is important to use the correct driver type as specified by the manufacturer. It is also important to check that the LED is dimmable. Some retrofits are not.