Temporary tables last throughout a session.
If your PostgreSQL client use connection pooling (connections are created lazily once a query is created), then it might give you a different connection (therefore different session) for each query.
Read how to reserve or isolate a connection from the pool in your client. If you want to make a transaction, follow your client's guide on making transactions so that it will use a reserved connection.