The extent of a layer can be set using a second layer, which acts as a mask. This recipe shows you how to do this.
To mask the DEM with the watershed mask, follow these steps:
watershed.tif layer and the dem.tif layer.
When using the raster calculator, all operations involving a no-data value will result in another no-data value. This means that, when multiplying the DEM layer and the mask layer, in the cells that contain no-data values in the mask layer, the value in the resulting layer will be a no-data value, no matter which elevation value is found in the DEM layer for this cell.
As cells inside the watershed in the mask layer have a value of 1, the result is a layer with elevation values for watershed cells and no-data values for the remaining ones.
Here are some additional ideas about masks.
Once we have masked the area of interest (in this case, the watershed), all analysis that we perform will be restricted to this. For instance, let's calculate the average elevation of the watershed:

These values have been computed using only valid cell values and ignoring the no-data ones, which means that they refer to the watershed and not the the full extent of the raster layer.
Sometimes, you might have more no-data values that are needed in a raster layer, as in the case of the proposed watershed layer. To reduce the extent of the layer and just have the minimum extent that covers the valid data, you can use the Crop to data algorithm:

Masking a raster layer can also be done using a polygon vector layer. The watershed.shp file contains a single polygon with the area of the watershed that we have already used to mask the DEM. Here is how to use this to mask that DEM without using the raster mask:
In this case, the clip algorithm automatically reduces the extent of the output layer to the minimum extent defined by the polygon layer, so there is no need to run the Crop to data algorithm afterwards.