Change post title if post has specific category

$post is undefined in your filter. You need to explicitely invoke the $post global inside your filter function to have it available. You must remember that variables (even global variables) outside a function will not be available inside a function, that is how PHP works.

You actually do not need to use the $post global, the post ID is passed by reference as second parameter to the the_title filter.

You can use the following:

add_action( 'the_title', 'adddd', 10, 2 );
function adddd( $title, $post_id ) 
{
    if( has_category( 30, $post_id ) ) {
        $title="Prefix " . $title;
    }

    return $title;
}

If you need to target only the titles of posts in the main query/loop, you can wrap your contional in an extra in_the_loop() condition