Why comets have tails?

Because the comet is going so fast there looks like the comet has a tail.