Replace text string on individual page

I can’t comment so I’ll answer and slightly adjust Bhagyashree’s which is exactly what you’ll need to do based on your question. Except you may want to know how to include the 2 pages rather than duplicating the function. And also passing in an array of strings to replace.

function replace_some_text( $content ) {
   
    // Notice the || we're saying if is page1 OR page2. Also changed to is_single.
    if( is_single( 2020 ) || is_single( 2021 ) {

       $text_strings_to_replace = array( 'first_string', 'second_string', 'third_string_to_replace' );

       $content = str_replace( $text_strings_to_replace, 'new_text', $content );
       
}

       return $content;
}

add_filter('the_content', 'replace_some_text');

Little explanation. Basically, we hook into a WordPress filter hook [add_filter][1] that allows us to filter all the content on the page.

We filter the $content inside our function, in this case using a PHP function [str_replace][1] to search the content for our array of strings and replace them with ‘new_text’.