It's down to the intermolecular forces.
In a liquid, the molecules are free to move about but are still stuck together. Therefore, you will have a quantifiable volume of liquid, but the because the particles move around within the structure of the liquid, you won't have a fixed shape (rather, the liquid will simply assume the shape of the container).
Gases, on the other hand, have negligible intermolecular attractions, and therefore can take up any given volume.
However, it is also worth noting that there are other factors that play into how much volume a gas can take up, namely pressure, volume and temperature. This is mathematically quantified by the ideal gas law:
Hope that helps :)