### Elasticsearch Version

8.3.2

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

Ubuntu 20.04.4 LTS

### Problem Description

When we have two legacy index templates and one of them defines the field name with dots (.), we may get mapper_parsing_exception.

### Steps to Reproduce

1. create two legacy index templates
```
PUT /_template/template1
{
  "order": 100,
  "index_patterns": [
    "haha*"
  ],
  "settings": {},
  "mappings": {
    "properties": {
      "kwm": {
        "properties": {
          "source": {
            "properties": {
              "geo": {
                "properties": {
                  "location": {
                    "type": "geo_point"
                  }
                }
              }
            }
          }
        }
      },
      "source": {
        "properties": {
          "geo": {
            "properties": {
              "location": {
                "type": "geo_point"
              }
            }
          }
        }
      }
    }
  }
}

PUT /_template/template2
{
  "order": 10,
  "index_patterns": [
    "haha*"
  ],
  "settings": {},
  "mappings": {
    "properties": {
      "kwm.source.geo": {
        "properties": {
          "location": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}
```
3. try to create an index
```
POST haha/_doc
{
}
```
it produces `mapper_parsing_exception` in `8.3.2` as below
```
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Field [source.geo.location] is defined more than once"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Field [source.geo.location] is defined more than once"
  },
  "status": 400
}
```
but no error in `8.2.3`

4. if we change the second index template `template2` as below:
```
PUT /_template/template2
{
  "order": 10,
  "index_patterns": [
    "haha*"
  ],
  "settings": {},
  "mappings": {
    "properties": {
      "kwm": {
        "properties": {
          "source": {
            "properties": {
              "geo": {
                "properties": {
                  "location": {
                    "type": "geo_point"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
```
we can create the `haha` index without errors in both `8.3.2` and `8.2.3`

I think we should not get `mapper_parsing_exception` in both `8.3.2` and `8.2.3` in the step 3 because `kwm.source.geo.location` field definition of two index templates are identical and `source.geo.location` is defined only in the `template1` index template.
I think this may be related with https://github.com/elastic/elasticsearch/pull/86166

### Logs (if relevant)

_No response_
server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
.setPatterns(Collections.singletonList("te*"))
            .setMapping("type", "type=keyword", "field", "type=text")
            .addAlias(new Alias("simple_alias"))
            .addAlias(new Alias("templated_alias-{index}"))
            .addAlias(new Alias("filtered_alias").filter("{\"term\":{\"type\":\"type2\"}}"))
            .addAlias(new Alias("complex_filtered_alias").filter(QueryBuilders.termsQuery("type", "typeX", "typeY", "typeZ")))
            .get();
        assertAcked(prepareCreate("test_index"));
        ensureGreen();
        client().prepareIndex("test_index").setId("1").setSource("type", "type1", "field", "A value").get();
        client().prepareIndex("test_index").setId("2").setSource("type", "type2", "field", "B value").get();
        client().prepareIndex("test_index").setId("3").setSource("type", "typeX", "field", "C value").get();
        client().prepareIndex("test_index").setId("4").setSource("type", "typeY", "field", "D value").get();
        client().prepareIndex("test_index").setId("5").setSource("type", "typeZ", "field", "E value").get();
        GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get();
        assertThat(getAliasesResponse.getAliases().size(), equalTo(1));
        assertThat(getAliasesResponse.getAliases().get("test_index").size(), equalTo(4));
        refresh();
        SearchResponse searchResponse = client().prepareSearch("test_index").get();
        assertHitCount(searchResponse, 5L);
        searchResponse = client().prepareSearch("simple_alias").get();
        assertHitCount(searchResponse, 5L);
        searchResponse = client().prepareSearch("templated_alias-test_index").get();
        assertHitCount(searchResponse, 5L);
        searchResponse = client().prepareSearch("filtered_alias").get();
        assertHitCount(searchResponse, 1L);
        assertThat(searchResponse.getHits().getAt(0).getSourceAsMap().get("type"), equalTo("type2"));
        
        searchResponse = client().prepareSearch("complex_filtered_alias").get();
        assertHitCount(searchResponse, 3L);