Weird PostgreSQL expression parsing
In the first example, you end up with 1 + 2 IS NOT NULL - which, it is not, 3 is certainly not null. 3 IS NOT NULL evaluates to true, casting it to an int makes it 1 again. Hopefully this makes it clearer:

testdb=# select 1 is not null;
 ?column? 
----------
 t
(1 row)

testdb=# select 1 is not null::int;
 int4 
------
    1
(1 row)

testdb=# select 1 is not null::int + 2;
 ?column? 
----------
        3
(1 row)

testdb=# select 1 is not null::int + 2 is not null;
 ?column? 
----------
 t
(1 row)

testdb=# select 1 is not null::int + 2 is not null::int;
 int4 
------
    1
(1 row)