I can't be 100% sure, but I think it has to with resetting. In the sense, if it is not there, you can simply go in and out of the building, sort of like a soft-er reset. Back then, games were made with a very tiny amount of memory, so moving to another location would sort of 'reset' the present conditions. Hence the slight time delay and the screen blackening while walking through the doors. That is when the game resets the coding, so you can probably see a roaming NPC repeat the same action. Of course, in most cases, this is subtle and you can't see the immediate difference, because as game developers their job is to cover up such stuff, but I assume it's always there, only, we can't see it.
Something similar happens in B/W as well. If you reopen your game after the date was changed to bring in another season, walking through the PokeCenter will change the season. This most notably seen if you save INSIDE the PokeCenter, so you get a black screen showing the (new) season before you walk out.
I am no game developer, but if I had to guess, this would be the reason. Buildings, having a smaller memory requirement due to their small size and limited pixels and coding required as compared to the outside world (specially in a game like Pokemon), are an easy way to help you out with in-game events like roaming Pokemon.
Anyway, this is just an (educated) guess of mine, and the real reason could be different.