Each creature dwelling has a certain "limit" parameter, which actually reflects its capacity (how many creatures it can accommodate). Limits can be basic, full (double), or enhanced (triple).
When a regular dwelling is built in a town, the basic limit of these troops is immediately available for hiring. When an upgrade is built, the full limit is available (in addition).
At the beginning of each week, all limits are updated: excess troops are evicted, or missing ones are added.
A Fort converts all basic weekly limits to full (double) limits.
A Stronghold converts the weekly limits of basic troops (levels 1-3) to enhanced (triple) limits, and also immediately provides the basic limits of these troops.
A Castle converts the weekly limits of elite troops (levels 4-6) to enhanced (triple) limits, and also immediately provides the basic limits of these troops.
Legendary troops (level 7 and Hydra level 6) are a separate case, as they are produced immediately with the full limit. There are no basic or enhanced limits for legendary troops.
External dwellings provide the full troop limit both immediately and weekly, and their capacity, unlike town dwellings, is not actually limited – creatures can accumulate. However, they do not provide any +1 bonuses to the player's towns.
All these limits only matter during hiring, because once recruited, the troops support themselves and are not limited in any way.
The limit system is introduced as a protection against passive accumulation. Now, simply building a dragon dwelling is not enough; you also need to manage to recruit a dragon before the end of the week so that the limit is replenished at the beginning of the next week and a new dragon appears. Due to the rebalancing of prices, this actually means that the player is buying dwellings at a huge discount in gold, which they must spend on recruiting the limit within the week.
For example, a dragon dwelling may cost only 2500 (+a lot of resources), while the dragon itself costs another 4000 (and 4 resources) to recruit. The cost of troops (in gold) is many times higher than the cost of the production building, which is a normal practice in successful strategies (like Starcraft). Since troops are a key element in the game, and not just support buildings.
Added 43 minutes later


The policy of "nice" or discrete prices is applied because accuracy is not so important here (the difference can be compensated for by the resources of the building). So you won't find skeletons costing 19 or shamans costing 360 here