### Elasticsearch Version

8.7.1

### Installed Plugins

_No response_

### Java Version

openjdk 20.0.1 2023-04-18

### OS Version

Linux 80ea76b172b2 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

### Problem Description

After upgrading from ES `8.6.2` to `8.7.1` I noticed that `params['_source']` value is wrong sometimes when it's accessed in `runtime_mappings` field's script as in:

```
"runtime_mappings": {
  "runtime_field": {
    "type": "keyword",
    "script": {
      "lang": "painless",
      "source": "emit(params['_source'].toString())"
    }
  }
}
```



### Steps to Reproduce

```
PUT foo_bar
{
  "mappings": {
    "properties": {
      "id": {
        "type": "text"
      },
      "name": {
        "type": "text",
        "fields": {
          "raw": {
            "type": "keyword"
          }
        }
      }
    }
  },
  "settings": {
    "index": {
      "number_of_shards": 3,
      "number_of_replicas": 2
    }
  }
}

POST foo_bar/_bulk?refresh=true
{"index":{}}
{"id":"1","name":"name 1"}
{"index":{}}
{"id":"2","name":"name 2"}
{"index":{}}
{"id":"3","name":"name 3"}
{"index":{}}

GET foo_bar/_search
{
  "size": 0,
  "runtime_mappings": {
    "runtime_field": {
      "type": "keyword",
      "script": {
        "lang": "painless",
        "source": "emit(params['_source'].toString())"
      }
    }
  },
  "fields": [
    "runtime_field"
  ],
  "aggs": {
    "aggregation": {
      "terms": {
        "field": "name.raw"
      },
      "aggs": {
        "hits": {
          "top_hits": {
            "_source": true
          }
        }
      }
    }
  },
  "from": 0
}

```

and result of this is:

```
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 3,
    "successful": 3,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 3,
      "relation": "eq"
    },
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "aggregation": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "name 1",
          "doc_count": 1,
          "hits": {
            "hits": {
              "total": {
                "value": 1,
                "relation": "eq"
              },
              "max_score": 1,
              "hits": [
                {
                  "_index": "foo_bar",
                  "_id": "TydRSIgB3P4C-UmlKFF0",
                  "_score": 1,
                  "_source": {
                    "id": "1",
                    "name": "name 1"
                  },
                  "fields": {
                    "runtime_field": [
                      "{id=1, name=name 1}"
                    ]
                  }
                }
              ]
            }
          }
        },
        {
          "key": "name 2",
          "doc_count": 1,
          "hits": {
            "hits": {
              "total": {
                "value": 1,
                "relation": "eq"
              },
              "max_score": 1,
              "hits": [
                {
                  "_index": "foo_bar",
                  "_id": "UCdRSIgB3P4C-UmlKFF0",
                  "_score": 1,
                  "_source": {
                    "id": "2",
                    "name": "name 2"
                  },
                  "fields": {
                    "runtime_field": [
                      "{id=2, name=name 2}"
                    ]
                  }
                }
              ]
            }
          }
        },
        {
          "key": "name 3",
          "doc_count": 1,
          "hits": {
            "hits": {
              "total": {
                "value": 1,
                "relation": "eq"
              },
              "max_score": 1,
              "hits": [
                {
                  "_index": "foo_bar",
                  "_id": "USdRSIgB3P4C-UmlKFF0",
                  "_score": 1,
                  "_source": {
                    "id": "3",
                    "name": "name 3"
                  },
                  "fields": {
                    "runtime_field": [
                      "{id=1, name=name 1}" # <----- It should be "{id=3, name=name 3}"
                    ]
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}
```

Please let me know if you need more info to investigate this

### Logs (if relevant)

_No response_
server/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java
boolean requiresSource,
        Profiler profiler,
        LeafNestedDocuments nestedDocuments,
        LeafStoredFieldLoader leafStoredFieldLoader,
        int docId,
        LeafReaderContext subReaderContext,
        SourceLoader.Leaf sourceLoader
    ) throws IOException {
        if (nestedDocuments.advance(docId - subReaderContext.docBase) == null) {
            return prepareNonNestedHitContext(requiresSource, profiler, leafStoredFieldLoader, docId, subReaderContext, sourceLoader);
        } else {
            return prepareNestedHitContext(
                context,
                requiresSource,
                profiler,
                docId,
                nestedDocuments,
                subReaderContext,
                leafStoredFieldLoader
            );
        }
    }
    /**
     * Resets the provided {@link HitContext} with information on the current
     * document. This includes the following:
     *   - Adding an initial {@link SearchHit} instance.
     *   - Loading the document source and setting it on {@link HitContext#source()}. This
     *     allows fetch subphases that use the hit context to access the preloaded source.
     */
    private static HitContext prepareNonNestedHitContext(