When something melts, freezes or turns into a gas, the only change is in the way the particles of the substance are held together.
In a solid, the particles of water are all locked firmly together. That is why solids don't change shape.
In a liquid, the particles still touch, but they are no longer locked together and can slip over one another. That is why liquids flow.
In a gas, the particles no longer touch, and are free to move wherever they want.