queried_object using pre_get_posts gets notices and warning

Do no modify the queried_object property, instead use the set methods to modify the query to achieve your desired output. Below example will work. Use only one of the query, page_id(when you are setting a page id) or post__in/p (when you are setting post_id’s array or a post_id respectively).

function replaceQuery( $query )  {
  
   if ( !is_admin() && $query->is_main_query() && $query->is_page ) {
    
     $childQuery = get_post(13);

     //to set/query multiple post ids
     $query->set( 'post__in', array( $childQuery->ID ) );

     //to set/query only a single post id
     $query->set( 'p', $childQuery->ID );

     //to set/query page id
     $query->set( 'page_id', $childQuery->ID );

  }

}
add_action( 'pre_get_posts', 'replaceQuery');