I'm thinking he was actually in an arena, maybe rehearsing or otherwise occupied, and the PM just happened by. The comments say that the flags were props. So it was a big surprise to him. He even looks surprised in the picture. I know the President could show up at my house and surprise me in my Betty Boop pajama pants. If a camera goes off, oh well.
If this was a formal occasion in Ottawa, then yes, very inappropriate.
(I say that as a non-fan).