How is it possible that a gallery doesn’t have attachment ids?

Prior to WordPress 3.5 there was no gallery editor, so the normal way of a gallery was inserted was just with the shortcode, which would output all images attached to (i.e. originally uploaded to) the post. This functionality still works for backwards compatibility reasons. If this sounds awful, then yes, yes it was.