“Undefined variable: array” Error In Displaying Post Tag

You are probably not getting into your first if – And therefore the $array is not defined, since you do it in that condition and also use it if $stats is not empty – Either define the $array before the
if($instance) or find another way 😀
so something like this, will get you on the right track

$array = array();
if ( $instance['stats_tag']['category'] ) {         
    $posttags = get_the_tags();
    if ($posttags) {

        foreach($posttags as $tag) {
        $link = get_tag_link($tag->term_id);
          $array[] = '<a href="' . esc_url( $link ) . '" rel="tag" itemprop="keywords">' . $tag->name . '</a>';

    }   
} 
if ( $stats != '' ) {
    $stats[] =  '<span class="the-day-tags">' . implode(', ', (array)$array). '</span>' ;
}