### Elasticsearch Version

8.5.0

### Installed Plugins

_No response_

### Java Version

elastic.co customer

### OS Version

elastic.co customer

### Problem Description

Dynamic mapping eagerly interprets a string with this format `2021-51` as a date field, but then fails to index due to 51 not being a valid month.

Expected behaviour would be to index `2021-51` as a text field.

### Steps to Reproduce

With [dynamic mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-mapping.html) turned on attempt to index this document in a fresh, empty index:

```http
POST /bugreport/_doc
{
  "not_a_date": "2022-51"
}
```

Returned error message is:
```json
{
  "error": {
    "root_cause": [
      {
        "type": "date_time_exception",
        "reason": "date_time_exception: Invalid value for MonthOfYear (valid values 1 - 12): 51"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [not_a_date] of type [date] in document with id 'U1f9Y4YBXO70bNmhk658'. Preview of field's value: '2022-51'",
    "caused_by": {
      "type": "date_time_exception",
      "reason": "date_time_exception: Invalid value for MonthOfYear (valid values 1 - 12): 51"
    }
  },
  "status": 400
}
```

### Logs (if relevant)

Mappings on index `bugreport`

```http
GET /bugreport/_mapping
```

```json
{
  "bugreport": {
    "mappings": {}
  }
}
```
server/src/main/java/org/elasticsearch/index/mapper/DynamicFieldsBuilder.java
* @param dateFormatter  a date formatter to use if the type is a date, null if not a date or is using the default format
     * @return true if a template was found and applied, false otherwise
     */
    private static boolean applyMatchingTemplate(
        DocumentParserContext context,
        String name,
        DynamicTemplate.XContentFieldType matchType,
        DateFormatter dateFormatter
    ) throws IOException {
        DynamicTemplate dynamicTemplate = context.findDynamicTemplate(name, matchType);
        if (dynamicTemplate == null) {
            return false;
        }
        String dynamicType = dynamicTemplate.isRuntimeMapping() ? matchType.defaultRuntimeMappingType() : matchType.defaultMappingType();
        String mappingType = dynamicTemplate.mappingType(dynamicType);
        Map<String, Object> mapping = dynamicTemplate.mappingForName(name, dynamicType);
        if (dynamicTemplate.isRuntimeMapping()) {
            MappingParserContext parserContext = context.dynamicTemplateParserContext(dateFormatter);
            RuntimeField.Parser parser = parserContext.runtimeFieldParser(mappingType);
            String fullName = context.path().pathAsText(name);
            if (parser == null) {
                throw new MapperParsingException("failed to find type parsed [" + mappingType + "] for [" + fullName + "]");
            }
            RuntimeField.Builder builder = parser.parse(fullName, mapping, parserContext);
            Runtime.createDynamicField(builder.createRuntimeField(parserContext), context);
        } else {
            Mapper.Builder builder = parseDynamicTemplateMapping(name, mappingType, mapping, dateFormatter, context);
            CONCRETE.createDynamicField(builder, context);
        }
        return true;