As per the discussion
the_content
is not a proper hook for filtering post titles while it filters the post content. wpautop()
function is called with the_content
so it adds the necessary paragraphs.
To filter post titles use the_title
instead, it won’t add any markup tags by default:
echo apply_filters('the_title', get_post_field('post_title', $post_id));