I think, your question is why the first one gives the type erasure related error while the first one does not. The answer is that when you compile the second code ie..
compiler generates the corresponding bite code as follows -
In this case, you can see that all the type information was erased and T was converted to Object.... Now think of the first code mentioned by you.. ie
In this case, you are using instance of operator on T. Java compiler did not give this as an option and declared this an error due to obvious reasons that converting (my instanceof T) to (my instanceof Object) after compilation would have confused many developers as they could have been doing it thinking a type safe operation but it wold have not been.