you don't need to know the exact math to understand it. Consider the theory: Time is money.
The amount of time a building will take, is a product of the cost of the building, and the industrial output of the city making it. When buying things, your primary goal is simply to "buy time". Specifically, to buy as much time as possible, for as little money as possible. This means there are several ways to prioritise your buying:
1. Buy more often in low-production cities. places with few materials that struggle to build their own things.
2. Buy industrial structures (workshops, lumber camps) so as to reduce the city's dependance on money in future.
3. Buy financial buildings (merchants, markets) so as to increase your capacity to buy more\
4. Buy time dependant things (like a garden, when the city has zero food) so as to save you from stagnation in your empire.
5. Buy resource production enhancements (especially crystal mines, warg dens, and influence-monuments) as these produce resources which you can sell to other factions, thus getting more money (see rule 3)