Downsampling in MATLAB - why scaling filter coefficients?
This is done to achieve unity gain, i.e. to have the same energy in the downsampled and original signal.

The sum of filter coefficients sum(h) is the filter gain, by dividing the filter by it, it is set to 1 (unity). 
It is multiplied by p to compensate for the missing samples, again to achieve the same engery as in the original signal.