People interested in nominating for an election on SO generally have about two weeks to decide whether they wish to nominate - the week of question collection and the week of nominations. There are no official announcements prior to this two-week period, though there are ways to figure out if an election has been scheduled.
The system generally works as follows:
- A decision is made to have an election and how many slots it should have - this usually is driven by the mods requesting it, though there have been times that the CMs propose it and it's accepted by the mods. In general, CMs do not force SO (or any site) to have an election.
- A time is found for the election on the calendar - because holding an election requires CM oversight, we restrict the number that occur at any given time. We're currently scheduling them for the quarter during the last month of the preceding quarter, though we leave room for emergency election needs.
- The election is scheduled in the system. At this point, the new election page is created with the incremented number. If you watch this page, you could theoretically know about the election in advance, assuming it was scheduled early.
- The election "begins" when the question collection post is created, the week prior to nominations opening. This post is traditionally featured in the bulletin.
- Nominations begin. Anyone who meets the criteria to nominate is sent a notification about the nominations being available (not actually certain we do this on SO, though).
- Voting begins. Anyone with sufficient reputation to vote gets an inbox notification inviting them to do so.
For elections that have primaries, there's a step between 5 and 6 that notifies people to vote in the primary.
So, to answer your main question, there are several ways to know that there's an election coming but we generally don't publicly announce it until question collection begins. That said, once the election is scheduled, it's not expected to be a secret.