Translation:Téann an buachaill timpeall na leabharlainne.
Please help me understand again why in the sentence you can't say timpeall an leabharlann?
An leabharlann is the nominative singular which you could use in a sentence like "Téann an buachaill go dtí an leabharlann" [The boy goes to the library].
Na leabharlainne is the genitive singular which is used in this sentence because it follows the preposition timpeall which is one of several that require use of the genitive case.
Adding (because I was confused) - for feminine nouns in the genitive, the singular article changes from 'an' to 'na' as well; and leabhalann is femine.
Does this sentence mean that the boy goes around the outside of the library building or that he moves around inside it?
Around the building. Timpeall can also mean "circuit", so this can be translated as "The boy makes a circuit of the library"