Mechanisms controlling magnetic properties of pseudobinary compounds TbNi5−xMx (M=Cu or Al)