Wikipedia says the pilot was filmed in March 2001, and production began in July 2001, so the broad strokes of the show were maybe mostly written prior to 9/11, but most of the actual filming likely happened after (which means writers also had time to rewrite at least some things).
I find it interesting that 24 format, total chronological order, allowed them to react to that 9/11 if it was required. Kinda like South Park episodes are at most 2-week old when aired. South Park it's easy since episodes aren't connected and due to how it's made, but the idea is the same.
I'm not a very TV or movie oriented person but I do find the way things are produced quite amazing. I lived in Los Angeles for years and saw many things being filmed as a result. It was always a treat, an extra fun when I saw it on TV later on.
Everything and everyone involved does incredible stuff, IMO.