Why does “if statement” has to “die()”, otherwise wont work?

Most likely it’s simply because $_GET['first'] is not defined when you try with ?second=case&id=204.

Instead, try this CODE (assuming first & second can’t appear at the same time):

if (isset($_GET['api'])) {
    if (isset($_GET['first']) && $_GET['first'] == 'case' && isset($_GET['id'])) {
         // $query is the WP_Query Object
        $post = get_post($_GET['id']);   // $post contains the post object   

        header("content-type: application/json");
        echo json_encode($post);
    }
    else if (isset($_GET['second']) && $_GET['second'] == 'case' && isset($_GET['id'])) {
        // $query is the WP_Query Object
        $post = get_post($_GET['id']);   // $post contains the post object   

        header("content-type: application/json");
        echo json_encode($post);
    }
    die();
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)