How does the module system actually work?

Yes, I believe this can happen. The import/using keywords depend on a module already being defined at the moment they run. So if they happen in an include before the include of the module errors will happen.