But, see, you guys are trying to come up with excuses for this ipso facto. "Well, the housekeeper was and old man inexperienced with this sort of thing and M was an aging, mortally wounded, bureaucrat so neither of them were in a position to know not to use the flashlight in such a manner under those circumstances or were thinking straight."
I somehow doubt that thought process were what the writers of the movie had in mind when they made the scene. (At the same time, I doubt they had it in mind that either or both were so incompetent at life that they didn't realize doing something like that was a bad idea.) It's just an inkling of poor writing. They needed a way for Silva to spot M in the distance and this was the best they could come up with. (As opposed to a variety of Bond-universe-ian gadgets they could have come up with. Like Silva's hack into MI6 gave him access to a drone or satellite with thermal imaging or something.) It's a bit of lazy writing, a deus ex machina. The characters act stupid pretty much because the script says they have to in order to get to the next scene.
It doesn't make Skyfall a bad movie, it just stands out as odd that in such a situation these two people would behave in such a manner to make their position VERY obvious and easily tracked.