Categories from front-end, checkbox selection doesn’t work

You changed the checkbox’s name attribute value. You should use the same name value: terms[$taxonomy][]

This should fix the code:

if (is_taxonomy_hierarchical($taxonomy))
        //$out .= "<input class="{$term->term_taxonomy_id}" type="checkbox" value="{$term->term_taxonomy_id}" name="{$term->term_taxonomy_id}" /> {$term->name}<br />";
        $out .= "<input class="{$term->term_taxonomy_id}" type="checkbox" value="{$term->term_taxonomy_id}" name="terms[{$taxonomy}][]" /> {$term->name}<br />";
    else
        // $out .= "<input class="{$term->term_taxonomy_id}" type="checkbox" value="{$term->name}" name="{$term->name}" /> {$term->name}";
        $out .= "<input class="{$term->term_taxonomy_id}" type="checkbox" value="{$term->name}" name="terms[{$taxonomy}][]" /> {$term->name}";
}