And why is this sentence" I shut the window before the bird had flown into the room." a little bit strange for a native English speaker? Have a look at above posts.
Because the other posts give information about something that happened before something else happened. That is not the case with the sentence about the bird. The bird
didn't fly into the room. If you had already shut the window, it was impossible for the bird to fly into the room.
5jj's suggestion "I shut the window before the bird could fly into the room" means "I shut the window in order to avoid the bird flying into the room".
"I shut the window before the bird flew into the room" could suggest that the bird did fly into the room but that it entered by some other portal. Perhaps it flew in through the door.
If, for some reason, you must use your sentence, you would have to say "I
had shut the window before the bird
flew into the room".