### 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/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java
b.startObject("properties");
            {
                b.startObject("bar").field("type", "integer").endObject();
            }
            b.endObject();
        }));
        ParsedDocument doc = mapper.parse(source(b -> b.field("field.bar", 123)));
        assertEquals(123, doc.docs().get(0).getNumericValue("field.bar"));
    }
    public void testUnexpectedFieldMappingType() throws Exception {
        DocumentMapper mapper = createDocumentMapper(mapping(b -> {
            b.startObject("foo").field("type", "long").endObject();
            b.startObject("bar").field("type", "boolean").endObject();
        }));
        {
            MapperException exception = expectThrows(MapperException.class, () -> mapper.parse(source(b -> b.field("foo", true))));
            assertThat(exception.getMessage(), containsString("failed to parse field [foo] of type [long] in document with id '1'"));
        }
        {
            MapperException exception = expectThrows(MapperException.class, () -> mapper.parse(source(b -> b.field("bar", "bar"))));
            assertThat(exception.getMessage(), containsString("failed to parse field [bar] of type [boolean] in document with id '1'"));
        }
    }
    public void testDotsWithDynamicNestedMapper() throws Exception {
        DocumentMapper mapper = createDocumentMapper(topMapping(b -> {
            b.startArray("dynamic_templates");
            {
                b.startObject();
                {
                    b.startObject("objects_as_nested");