Sakura did a sneak attack on her while Kaguya was busy dodging Naruto and Sasuke. Kaguya did notice, The exclamation mark proves that, but she was not able to react in time to dodge her punch.
She was looking down at Naruto & Sasuke (her main priority)
But she has Byakugan, in the top left panel Sakura was not behind her neck
The Byakugan has a small blind spot near the behind of the neck. (Read Kidomaru VS Neji Part 1 fight for reference). Sakura perhaps knew this and attacked Kaguya in her blind spot. Kaguya sensed her chakra (That's why the exclamation mark) but because of her fast movement speed, she was not able to react in time.
Oh, I see, well if she noticed Sakura that soon...
Well do you remember how BZ got close to madara even tho he had 4 limbos guarding him from all sides?yeah this the same thing, and it's called "plot"...........