Why do comets have tails?

A simplistic answer according to the article "Comets: Formation, Discovery and Exploration" (Choi, 2010) is as the comet (which is a lump of 'dirty ice') approaches the sun, the radiation emitted causes the ice to melt into a 'coma', and then blown out into a tail in the solar wind.

Going further, from the webpage "Why do some comets have two tails?", it is noted that the formation of the tail is actually in two parts, from the website:

The gas can be come 'photoionized' by the harsh ultraviolet light from the Sun, so that comet tails contain a complicated mixture of dust, ionized gas and neutral gas, illustrated below.

comets

The reason for two tails that you see there is

cometary ionized and neutral gases go one way in space because they are effected by the magnetic fields and gases in the solar wind.

and

generally, the dust tails follow along the orbit of the comet