Problem with $post_id object’s property

I consider this question to be borderline unanswerable. It really depends on context.

In your example $post is whatever that global has been set to. That is pretty general, pretty obvious, and not really saying much but without knowing the context in which this code executes it is hard to give a better answer.

That variable is set for each post in the Loop by setup_postdata or the_post and it is set on some back-end pages in similar ways, based ultimately in $_GET or $_POST data whether that $_GET or $_POST data contains a post ID or components of a query.

Many of the hooks and filters that you use are passed that value so it is not always necessary to grab the global directly.