A code is perfect if the balls of radius e centered at codewords cover the whole vector space. The Hamming bound is obtained by counting the number of vectors

contained in disjoint balls of radius e centered around codewords (left hand side). This is less than or equal to the number of vectors in the whole vector space

(right hand side). So, the difference in the LHS and RHS in the Hamming bound comes from the vectors that are NOT covered by balls of radius e centered around codewords.

But, for a perfect code, there are no such vectors, hence we have equality in the Hamming bound.