WordPress retrieving $post based on random key in $_POST

While I was typing up this question, I left it for a while, found out the problem, and decided to post the answer just in case it helped anyone else. Apparently, in WordPress’s infinite wisdom, it decided to make this argument in its register_post_types function:

'publicly_queryable'

When this is set to true, it causes this weird phenomenon. When it is set to false, it fixes this issue.