Limit title length

It’s because you’re not using the filter correctly. The the_title filter passes the title to be filtered as the $title argument, but you’re overwriting it with this code:

global $post;
$id = ($post->ID);
$title = get_post( $id )->post_title;

That code’s completely unnecessary because the title is already available in your function:

function max_title_length( $title ) {

So simply remove those lines to filter the correct title:

function max_title_length( $title ) {
    $max = 20;

    if ( strlen( $title ) > $max ) {
        return substr( $title, 0, $max ) . ' …';  
    } else {
        return $title;
    }
}
add_filter( 'the_title', 'max_title_length' );

Just be aware that — as you’ve experienced — the the_title filter applies to all titles, including posts, pages, and menu items. So if you only want your code to apply to titles output within The Loop, you can use the in_the_loop() function:

function max_title_length( $title ) {
    $max = 20;

    if ( in_the_loop() && strlen( $title ) > $max ) {
        return substr( $title, 0, $max ) . ' …';  
    } else {
        return $title;
    }
}
add_filter( 'the_title', 'max_title_length' );