What is the difference between a Viewer and a Compositor node?
As per the manual
They are two of several output nodes and allow you see or save the working image in progress. At any point only one viewer and one composite node is active.

The Viewer node is a temporary, in-process viewer. Plug it in wherever
you would like to see an image or value-map in your node-tree.

and

The Composite node is where the actual output from the compositor is
connected to the renderer. Connecting a node to the Composite node
will output the result of that node's full tree to the Renderer,
leaving this node unconnected will result in a blank image. This node
is updated after each render, but also if you change things in your
node-tree (provided at least one finished input node is connected).