The ability to control the transition from a two-dimensional (2D) monolayer to the three-dimensional (3D) molecular structure in the growth of organic layers on surfaces is essential for the production of functional thin films and devices. This has, however, proved to be extremely challenging, starting from the currently limited ability to attain a molecular scale characterization of this transition. Here, through innovative application of low-dose electron diffraction and aberration-corrected transmission electron microscopy (acTEM), combined with scanning tunneling microscopy (STM), we reveal the structural changes occurring as film thickness is increased from monolayer to tens of nanometers for supramolecular assembly of two prototypical benzenecarboxylic acids - terephthalic acid (TPA) and trimesic acid (TMA) - on graphene. The intermolecular hydrogen bonding in these molecules is similar and both form well-ordered monolayers on graphene, but their structural transitions with film thickness are very different. While the structure of TPA thin films varies continuously towards the 3D lattice, TMA retains its planar monolayer structure up to a critical thickness, after which a transition to a polycrystalline film occurs. These distinctive structural evolutions can be rationalized in terms of the topological differences in the 3D crystallography of the two molecules. The templated 2D structure of TPA can smoothly map to its 3D structure through continuous molecular tilting within the unit cell, whilst the 3D structure of TMA is topologically distinct from its 2D form, so that only an abrupt transition is possible. The concept of topological protection of the 2D structure gives a new tool for the molecular design of nanostructured films.