tl;dr: The slow sublimation rate over 4 days rules out CO2 as the primary component (which would have sublimated much more quickly when exposed to the warm-ish atmosphere and sunlight), and careful measurement of the strong downward slope in reflectivity in the near infrared at about 1 micron from hyperspectral imaging demonstrates ~99% water ice for at least one of the locations.
I'll add to @Andrew's excellent answer
The Phoenix Lander's Surface stereo imager is a pair of cameras equipped with rotating filter wheels that allow it to do multispectral imaging which is a coarse form of imaging spectroscopy. The two wheels are geared together and have twelve positions.
From M. T. Lemmon et al. (2008) The Phoenix Surface Stereo Imager (SSI) Investigation (Lunar and Planetary Science XXXIX (2008)) (also here):
The filter wheel contains red and blue matched ste- reo pairs, 6 neutral density filters for atmospheric dust and water vapor measurements, a total of 13 unique multispectral bands, infrared and blue diopters for deck images, and an infrared linear polarizer. Color and diopter filters are held in the right eye; infrared filters are in the left. Table 1 shows the SSI filter set. Most filters are in best focus near 3 m, with good focus from 2 m to infinity; the deck filters are in focus at 1- 1.4 m.
click for larger left: Figure 1. The SSI camera head. right: Table 1. SSI filters.
From P. H. Smith et al. (2001) The MVACS Surface Stereo Imager on Mars Polar Lander we can see the detailed band passes of each filter
click for larger
Figure 8. (a) Geology filter relative spectral response at T = -20øC for all 12 filters listed in Table 4. (b) Solar filter profiles for the filters in Table 5.
And from Cull et al. (2010) Compositions of subsurface ices at the Mars Phoenix landing site linked in @Andrew's answer we can see how these are used to identify the ice as water ice:
Figure 4. (a) Comparing 1.001 μm band depths in various model results. Any composition with >1 wt% soil masks the 1.001 μm absorption, illustrating that Dodo-Goldilocks must be at least 99wt% pure water ice. (b) Freshly exposed (<2 hours old) ice at the Snow White trench (thick line) vs. model results of ice-soil mixtures. The shorter wavelengths do not fit the observed spectrum; however, this is expected due to the soil analog used in the model. The overall albedo and shape of the longer wavelengths is the basis for our interpretation of 30 wt% +/− 20 wt %”.
So what makes them so confident it's water ice?
It's that dip in reflectivity at around 1 micron.
Although modeling was unable to produce exact ice:soil ratios, it has constrained the ice fraction in both the Dodo-Goldilocks and Snow White types of ice. Because the 1.001 μm slope is not masked in Dodo-Goldilocks ices, Dodo-Goldilocks must be at least 99wt% pure water ice. The Snow White ices are estimated to have <50 wt% ice, with a best fit of ∼30 ± 20 wt% ice. These estimates are consistent with other Phoenix observations: ∼30 wt% ice is ∼55 vol.% ice, which is consistent with Thermal and Electrical Conductivity Probe (TECP) estimates of 50–55% porosity for average ice-free soils derived from measured heat capacity [Hudson et al., 2009; Zent et al., 2010]. If ice were to diffuse into this soil, filling the pore space, it would represent ∼50–55 vol.% of the mixture.
See Phoenix (spacecraft); Thermal and Electrical Conductivity Probe (TECP).
Here's some examples the downward slop at 1 micron from reflectivity (albedo) measurements from snow on Earth, from Reflective properties of white sea ice and snow I chose some examples with easy-to-recognize snow but there are many more in the paper and they all show this sharp downward slope at 1 micron.
I think there can be a phase diagram and sublimation rate argument as well but I am not sure. CO2 ice does happen on Mars, mostly at the pole that happens to be experiencing winter midnight (i.e. no sunshine) but it can also happen sub-surface even when sunlight is present at the surface, so this is a good question to ask.
Update: From Wikipedia's Phoenix (spacecraft) Presence of shallow subsurface water ice:
On June 19, 2008 (sol 24), NASA announced that dice-sized clumps of bright material in the "Dodo-Goldilocks" trench dug by the robotic arm had vaporized over the course of four days, strongly implying that they were composed of water ice which sublimed following exposure. While dry ice also sublimes, under the conditions present it would do so at a rate much faster than observed. (three references cited)
From Planetary Society's 2008 Phoenix Scientists Confirm Water-Ice on Mars (archived)):
"We believe these things are water-ice," Lemmon reiterated during the press conference. "In the course of sitting through the very cold but dry Martian environment and having sunshine on them in the morning, they sublimated. Salt does not behave like that." They couldn't have been carbon-dioxide (CO2) ice at the local temperatures, because that material would not have been stable for even a day as a solid, he said.
...images that show sublimation of ice in the trench informally called "Dodo-Goldilocks" over the course of four days. Image credit: NASA/JPL-Caltech/University of Arizona/Texas A&M University
From nasa.gov/mission_pages Bright Chunks at Phoenix Lander's Mars Site Must Have Been Ice 06.19.08
From Chemistry SE's Which “exotic salt” can lower water's freezing point by 70 °C?:
Blobs of possible brine (really salty water) imaged on one of Phoenix’s landing struts shortly after arriving on Mars. Credit: NASA/JPL-Caltech/University of Arizona/Max Planck Institute
Exposing the water ice to sunshine likely lead to its sublimation, explaining it's gradual disappearance. Interestingly water condensed on some cold, shadowed areas under the Phoenix lander and remained liquid somehow. It is hypothesized that the extreme concentration of salt allowed it to remain liquid for a while at -70 C.
It's not clear to me yet if the water in these droplets is hypothesized to come directly from sublimation of the ice shown in the photos or not.
As M. T. Lemmon et al. (2008) The Phoenix Surface Stereo Imager (SSI) Investigation (Lunar and Planetary Science XXXIX (2008)) (also here) point out:
Phoenix includes a tell-tale for wind measurements, and SSI is used to monitor the tell-tale.
above: GIF from images transmitted from Mars. From the The Telltale project page on the Mars Simulation Laboratory. Also archived here.