How to implement post/redirect/get pattern on contact form

You could use the admin_post URL and actions to process form input and then redirect back to your page.

The form:

<form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
  <input type="hidden" name="action" value="do_something">
  <input type="hidden" name="origin" value="<?php the_ID(); ?>">
  <input type="submit" value="Submit">
</form>

Then the action:

add_action( 'admin_post_do_something', 'wpd_do_something' );
add_action( 'admin_post_nopriv_do_something', 'wpd_do_something' );

function wpd_do_something() {
    // do something, then...
    wp_redirect( get_permalink( $_REQUEST['origin'] ) );
    exit();
}