Query to get data of a post, if in category?

Your query won’t work as it will simply ignore your taxonomy query. This is not a bug but expected behavior.

When using p as your parameter, every other query parameter are ignored/bypassed like for example post_type, tax_query and any taxonomy related queries like category and tag parameters due to the fact that you are directly querying specific posts by reference.

I’m not sure what you are trying to achieve here, but you need to have a look at WP_Query and all of its available parameters and use those that are directly relevant to what you need. Also, this can be a structural or planning problem on your side which will maybe need you to rethink what you are trying to do and achieve

EDIT

From the comments

That sort of makes sense, but actually has_password, post_status, maybe others, will correctly filter whether or not to return the post in this case

That you have to go and play around with and check the SQL request. AFAIK, if you directly querying a post with p, it will return the post regardless. I still don’t fully understand what exactly happens within the WP_Query class.

The current source code for the WP_Query class compromise of 3716 lines of code, that is excluding the first section in the query.php file where the conditional functions are defined

That is way too much to wrap your head around. IMHO, I think the best way will be to do some test yourself and test different scenarios and checking that against the source code. I don’t really believe that this is a day’s work. You will go mad if you really try and understand and know what is happening in WP_Query in a day or two, maybe also a month 🙂