Here is an URL that saves some data from the DEM layer into a tiff file. I selected tiff because I guessed that it migh deliver data with higher bit depth than 8 bit per band. The attached gdalinfo report shows that it is not the case. What you are getting from the service with GetMap is just an image of the DEM but it does not contain real DEM data.
curl "http://geoserveis.icgc.cat/icgc_mdt2m/wms/service?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&WIDTH=1601&HEIGHT=835&LAYERS=MET2m&TRANSPARENT=TRUE&FORMAT=image%2Ftiff&BBOX=41.73789833892216,1.1666825875312856,42.01488889221557,1.6977746543848833&CRS=EPSG:4230&STYLES=" -o dem.tif
gdalinfo dem.tif -stats
Driver: GTiff/GeoTIFF
Files: dem.tif
Size is 1601, 835
Metadata:
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
TIFFTAG_XRESOLUTION=96
TIFFTAG_YRESOLUTION=96
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 835.0)
Upper Right ( 1601.0, 0.0)
Lower Right ( 1601.0, 835.0)
Center ( 800.5, 417.5)
Band 1 Block=1601x8 Type=Byte, ColorInterp=Red
Minimum=52.000, Maximum=147.000, Mean=92.948, StdDev=19.269
Metadata:
STATISTICS_MAXIMUM=147
STATISTICS_MEAN=92.947795352456
STATISTICS_MINIMUM=52
STATISTICS_STDDEV=19.269070509899
STATISTICS_VALID_PERCENT=100
Band 2 Block=1601x8 Type=Byte, ColorInterp=Green
Minimum=52.000, Maximum=147.000, Mean=92.948, StdDev=19.269
Metadata:
STATISTICS_MAXIMUM=147
STATISTICS_MEAN=92.947795352456
STATISTICS_MINIMUM=52
STATISTICS_STDDEV=19.269070509899
STATISTICS_VALID_PERCENT=100
Band 3 Block=1601x8 Type=Byte, ColorInterp=Blue
Minimum=52.000, Maximum=147.000, Mean=92.948, StdDev=19.269
Metadata:
STATISTICS_MAXIMUM=147
STATISTICS_MEAN=92.947795352456
STATISTICS_MINIMUM=52
STATISTICS_STDDEV=19.269070509899
STATISTICS_VALID_PERCENT=100
Thus band 1 is 8 bit, the available data range is 0-255 and image is actually using range 52-147. If you have only this image it is impossible to convert the pixel values with corresponding terrain heights.
The WMS service seems to support also GetFeatureInfo request that returns the following data from a clicked point:
Stretchedvalue PixelValue;
59 543.890015;
Here the PixelValue is probably the pixel value in the source DEM and StretchedValue how it is mapped into the 0-255 range of the WMS GetMap output. PixelValue may well tell the height directly: 543.89 meters. Unfortunately there is no way for getting the mapping between values of the source pixels and GetMap pixels from WMS server.
If nothing else exist and you are in an ultimage trouble you could make such look-up table be clicking around the map with GetFeatureInfo and writing the results into spreadsheet but still the resolution of an 8 bit image is pretty poor for a DEM. You do not have good chance for creating contours with accurate height values if you base your work on this WMS service.