What is the main difference between a decoder and a demultiplexer
They're nearly the same thing. A decoder selects one of n outputs based on a set of select lines.
If the device also has an enable, the decoder can be used to distribute a signal (the enable state) to a selected output. This is a demultiplexer. Internally, each decoder output is logical AND with the shared enable.
You'll often see decoders with enables referred to as 'decoder/demultiplexer'. Example: the 'HC138 https://www.ti.com/lit/ds/symlink/sn74hc138-q1.pdf
There’s another type of demultiplexer that uses a switch (transmission gate) element to pass a selected signal. Because they behave as switches, they can be used for digital or analog signals, and they work in both directions. This means they can be used as multiplexers too. Another benefit of transmission-gate switching is reduced delay.