The planet you are referring to is not a planet, but a celestial object called a comet. Comets are made up of frozen gas, rock, and dust and can develop a visible "tail" when they get close to the sun due to the heat causing the ice to vaporize and release gas and dust particles.