How to put a before and after with tags in a wordpress entry?

You can use get_adjacent_post() to get the nexy/prev post by tag. I think this should work,

// get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy )
$next_post = get_adjacent_post( true, '', false, 'post_tag' );
$prev_post = get_adjacent_post( true, '', true, 'post_tag' );

if ( $prev_post instanceof WP_Post ) {
  printf(
    '<div class="alignleft"><a href="https://wordpress.stackexchange.com/questions/345428/%s">&laquo; %s</a></div>',
    esc_url( get_permalink( $prev_post->ID ) ),
    esc_html( $prev_post->post_title )
  );
}

if ( $next_post instanceof WP_Post ) {
  printf(
    '<div class="alignright"><a href="https://wordpress.stackexchange.com/questions/345428/%s">%s &laquo;</a></div>',
    esc_url( get_permalink( $next_post->ID ) ),
    esc_html( $next_post->post_title )
  );
}