The U.S. Capitol Building has direct access to the Library of Congress via a tunnel.
If you are planning to visit both the U.S. Capitol Building and the Library of Congress, go to the Capitol first and then take the tunnel to the Jefferson Building. That way, you only have to go through security once.