Nasa has provided the following explanation: "Not every flag needs a breeze – at least not in space. When astronauts were planting the flagpole they rotated it back and forth to better penetrate the lunar soil – anyone who’s set a blunt tent post will know how this works.
So of course, the flag waved. Unfurling a piece of rolled-up cloth with sore angular momentum will naturally result in waves and ripples – no breeze required.”