Visited yesterday and was amazed by how big it was and I just don’t understand how they could build something so large and detailed without modern machinery. Tried looking it up but couldn’t find much.
The short answer is: gradually.
Although the first stones of the foundation were laid in 1506, the cupola was finished in 1590, the facade in 1614, and Bernini's plaza in 1667.
The scale of the edifice was made possible by the immense resources of the Church. Besides serving as absolute monarchs over the Papal States, the popes received tithes from across Catholic Europe, and offerings from a steady stream of pilgrims. To finance the basilica's construction, Leo X tried to supplement these regular sources of income with the sale of indulgences - a policy that famously sparked the Protestant Reformation.
The colossal dome was designed, but not actually constructed, by Michelangelo, who died after completing the drum. The cupola itself, completed by Giacomo della Porta, borrowed its basic design from Brunelleschi's famous "double shell" dome for the Duomo in Florence.
Beside attesting to papal wealth and Renaissance engineering advances, St. Peter's bears witness to the ambitions of successive popes to glorify themselves, their families, and the Catholic Church (sometimes in that order) with a monument of unprecedented splendor.
I recommend R. A. Scotti's Basilica, which provides a thorough and very readable account of the church's construction.
In addition to the excellent reply made by u/toldinstone, may I recommend G.E. Gordon's book Structures, or why things don't fall down.? It was originally recommended to me by two civil engineers, on separate occasions and is a very accessible, and funny, description of how structures work, with considerable discussion of Ancient World and Medieval building techniques (alongside bridges, ships, aeroplanes, and a history of civil engineering theory).
One of the techniques of mediaeval architects was to build models: the nature of stone and brick buildings is that the strength of stone and bricks in compression is way above the weight of even a very large building, so such buildings scale up fairly well. Builders could be reasonably confident that if a small model stands up (small might be metres in length admittedly), then a big version probably will too. This allowed people to build really big buildings without much modern technology or modern understanding of structures. (This is not to diminish the complexity of organising all the materials and workers and so forth, they were grand and hard accomplishments.)
The scale principle does not apply to ships or planes, thus why we only see really big ships after the development of cheap iron and steel.