We know that the magnetic field or magnetic flux is continuously changing in a transformer as the AC changes its polarity and magnitude. We also know that the core of the transformer is made of Iron and it laminated. So when the changing magnetic flux conducts through the iron core, it changes its shape also.
The humming also depends upon the core lamination. If the lamination is not properly done then it will create more noise. So loose clamping and poor stacking are increases the chances of humming.