Temperature is a state variable that does not depend on the amount of substance present whereas thermal energy can vary depending on the amount of substance. For example, if you had a swimming pool containing water at 300K it would contain much more thermal energy than a shot glass containing water at 300K.