Positioning Anchor Links, 2 different ways

This one doesn’t use a negative margin, this one uses flex, but how do you remove the overflow from it?

And why is it even there to begin with?

That doesn’t make sense at all.

#2