As has been pointed out several times, a "window" was originally an opportunity.
The source of the metaphor was probably a service window: a teller's window at a bank, a ticket window at a train station, a betting window at a horse track. While it was open, business could be conducted, but once it shut, you "missed your window".
It was easily extended to situation where circumstances -- particularly weather -- allowed a stretch of time during which a mission or project could be undertaken; too early, and especially too late, the mission or project would fail.
If you imagine a calendar with all the unfavorable dates and times blacked out and the one suitable period left as an unmarked rectangle of blank paper, the idea of a "window" of time becomes unmistakable.
Sadly, the idea of a window has been rather disgustingly reversed by service companies, most notably cable companies. The company declares a "window" that you must keep open, in the hope that their representative will deign to arrive. A window of seven to four (i.e. 7am to 4pm) has gone beyond arrogance to outright insult: the cable guy will arrive sometime that day.
If you're lucky.