Eigenspaces of Hamming graphs and unitary Cayley graphs