In file1.cyou have identified
int a;
which tells the compiler to allocate memory for ain this compilation module, all references to it awill be resolved there by the compiler (and not the linker). So, file1sees his own aand file1sees his own a. If you used instead,
extern int a;
file1, , a file2.c.
file2 , a , file2.so file2.h,
extern int a;
file2.h #include d file1.c.