I recently did a rasterize in QGIS with our city map (which I clipped from the whole country map before) to produce the first map. Now I need to do the connectivity analysis in another software so I did a rasterize and produced the second map with the "extra extent."
The raster will be always a rectangle. Hence, the black pixels are always present there. As in the comments above, usually all pixels of this black area have one value which is considered "no data". If QGis (transparency settings in 2.18) knows which value it is, it renders this area transparent so that it seems like the black area is not present but it is still there.
If you perform "Clip Raster by Mask Layer" the result will have always no-data values for all the areas outside the mask layer, i.e. the process does not reduce the extent of the input raster.
Note: In the previous raster, there are complete rows with no-data on top of the image.
If you want to remove the extra no-data cells, you can additionally perform a "Clip Raster by Extent", using the extent coordinates of the mask layer
Note: The last one raster does not have extra no-data cells (complete lines or columns!) outside the area of interest. You can use the Transparency - No Data Value to change the black color (to transparent) in the raster (generally cell values equal to 0)