BUG: guess_datetime_format fails to infer timeformat
- [x] closes #57452(Replace xxxx with the GitHub issue number)
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

Explanation of the fix:

The previous code below failed for date time str of the kind like "2023-11-09T20:23:46".

In L1006, `parsed_formatted` is parsed to the same "2023" for both "%H%M" and "%Y", then in L1010 format_guess[0] becomes "%H%M", rather than the correct "%Y". Noticing the order in `datetime_attrs_to_format`, I thus move "%Y" before "%H%M" to fix the bug.

https://github.com/pandas-dev/pandas/blob/63dc0f76faa208450b8aaa57246029fcf94d015b/pandas/_libs/tslibs/parsing.pyx#L996-L1013 it's been a while since I looked at this function :) taking a look today, thanks for the fix