The WordPress “gallery” functionality partly depends on the attachment of the media to the post via the post_parent
column.
Specifying IDs in your shortcode allows you to include images in your
gallery that aren’t necessarily “attached” to your post — that is to
say, not uploaded from within your post or page. This flexibility
allows you to create and embed any number of galleries containing any
number of images!Note: If you choose to just use the “barebones” version of the
shortcode in your post or page, only images that are
“attached” to that post or page will be displayed.
You can see in the source that shortcode uses get_children
, which has quite a comment block in the source, and again you can see that post_parent
is a key factor.
There are probably other ways to answer the questions but that is the first that comes to my mind.