Exclude page ID AND current page from wp_query of a Parent page

You can use get_the_ID() to retrieve the current page’s ID.

$current_page_id = get_the_ID();

$args = array(
    'post_type' => 'page',
    'posts_per_page' => -1,
    'post_parent' => '2',
    'post__not_in' => array( 4, $current_page_id ),
    'order' => 'ASC',
    'orderby' => 'menu_order'
); 

This kind of ID exclusion may cause query performance issues, especially when you have a great number of posts. So another option is to do a simple if check within the posts loop and skip certain post(s).

if ( $children->have_posts() ) {
    $current_page_id = get_the_ID(); // ID of the page you're on
    
    while ( $children->have_posts() ) {
        $children->the_post();
        // compare loop iteration child page ID to the page ID
        if ( get_the_ID() === $current_page_id ) {
            continue;
        }
        ?>
        <p><?php the_title(); ?></p>
        <?php
    }
}

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino