Modern scientific and mathematical knowledge was not necessary for building structures that would last a long time. For that, empirical knowledge, based on experience, was sufficient.
History of structural engineering:
Pyramids were the most common major structures built by ancient civilizations because the structural form of a pyramid is inherently stable and can be almost infinitely scaled (as opposed to most other structural forms, which cannot be linearly increased in size in proportion to increased loads)
Throughout ancient and medieval history most architectural design and
construction was carried out by artisans, such as stone masons and
carpenters, rising to the role of master builder. No theory of
structures existed and understanding of how structures stood up was
extremely limited, and based almost entirely on empirical evidence of
'what had worked before'. Knowledge was retained by guilds and seldom
supplanted by advances. Structures were repetitive, and increases in
scale were incremental.
It requires no sophisticated math or modern engineering knowledge to build simple structures, even though they are quite large and durable - you simply rely on your experience of what worked before and take it to the next small step.
Modern advances were required only when structures became more complex and sophisticated: Increased ratio of bulk vs usable space - size vs load, for example modern skyscrapers; spanning large expanses of space, for example modern suspension and cantilever bridges; building large, complex forms, for example the Guggenheim Museum; building structures based not on previous experience, but on mathematical predictions, for example the Tacoma-Narrows bridge. (That one didn't work out too well, but it's a well known example...)
Source: Understanding the World's Greatest Structures: Science and Innovation from Antiquity to Modernity - Lectures 1,2 - Professor Stephen Ressler, United States Military Academy at West Point Ph.D., Lehigh University.