The bees build up (and swarm) in spring when the going is good, much like many other animals that reproduce in spring. As spring becomes summer numbers in the colony begin to decrease and they become less likely to swarm (though it can still happen)
Graph below shows the approx colony population through the year.
Src:
Understanding Colony Buildup and Decline - Part 2 - Scientific Beekeeping
If the bees are looking to swarm they'll start making replacement queens in "swarm cells." Eggs are laid in these cells, hatch into larvae, and the cells are capped 7.5 days after laying. When the first queen cell is capped the old queen will swarm (weather permitting!). This is why, from April through to July, weekly inspections are required - if you see queen cells with eggs/larvae in them you can do something about it.