Group child category IDs based on their parent category

The quick take would be something like this:

$categories        = [ ];
$parent_categories = get_categories( [ 'parent' => 0 ] );

foreach ( $parent_categories as $parent_category ) {
    $id                = $parent_category->term_id;
    $categories[ $id ] = wp_list_pluck( get_categories( [ 'parent' => $id ] ), 'term_id' );
}

The important bit is a parent argument, which limits retrieved to immediate children (parent of 0 is a top level).

Depending on how many of these you have it might be preferable to instead retrieve all of them first and then re-arrange out of singe result set.