The reason you don’t see it if you dump object is because it’s not actual object property.
WP_Post
implements magical __get()
method for ancestors
and several more keys like that. When you access $post->ancestors()
what you actually get is not some value from the object, but return of get_post_ancestors()
function executed on it.
So in a nutshell this is like a virtual API shortcut.