In the first example, the compiler is able to check the delcared types of your variables, and it knows that they are not compatible for assignment or comparison. It's no different than trying to do:
boolean b = false;
double d = 5.5;
if (d == b) //compiler error, incompatible types.
Remember that
Java is a strongly typed language. That means you can't just assign everything to everything else. Assignment only works on compatible types.
In your interface example, a reference variable of an interface type has to hold an actual object at run time. So the compiler has to allow for the possibility that the actual object in a at runtime might be a subclass of a that implements the interface. It is "possible", so the compiler will allow it. Like you said, at runtime, a real check is made to see if your assignment makes sense, and if not you get an exception.