Because the military has people that do nothing all day but plan for stuff. The US (and it's NATO allies) have plans for all types of things. Hell, the US has plans for the invasion of Canada. The military doesn't sit around waiting for sh*t to happen and then figure out what to do. That would be stupid.
That is something else entirely. I'm talking about solid plans with definite times and dates. There is more than enough evidence that Bush knew he was going to invade Afghanistan long before 9/11.