How is WordPress changing the content markup?

WordPress runs a filter on the content to automatically add paragraphs: wpautop. You can remove the filter from all your post’s content if you like:

remove_filter('the_content','wpautop');

Alternatively, you can check out the Disabler plugin which can do this for you.

If you want to remove the filter from particular post(s) you can do:

add_filter('the_content','maybe_remove_wpautop',9);
function maybe_remove_wpautop($content) {
    global $post;
    // add post iDs for which you do not want autoparagraphs
    $nowpautopposts = array('23','47');
    if (in_array($post->ID,$nowpautopposts)) {remove_filter('the_content','wpautop');}
    return $content;
}

It should also be noted that some formatting is processed when you switch between the Text and Visual tabs on the writing screen. This is a much more complex problem, if you want to remove that you can try Preserve HTML Markup Plus plugin.

Update:

After the question was updated, the way to get the processed block of HTML code from the content is to use the following:

// (if you don't already have the post object)
global $post;
$post = get_post($postid);

// apply the content filters to the post object contents
$content = apply_filters('the_content', $post->post_content);

This will apply the existing content filters to the post’s content.

I have added the better practice of making sure you set the global $post to the post object from a post ID, because it is entirely possible some plugins could use the $post object inside their filter conditions and you want to make sure (as for example the previous code given needs this.)

On that note sometimes you may want to remove and re-add certain plugin content filters if you want to get the content without them, but you need to be specific. eg. if you ever did want the processed content without the autoparaghs (say if you want to add them yourself a different way) you could do this instead:

remove_filter('the_content','wpautop');
$content = apply_filters('the_content', $post->post_content);
$add_filter('the_content','wpautop');