Summary
In Sphinx-based rendering section indexes hold only the anchors below the current place, for example:

https://docs.typo3.org/m/typo3/reference-tsconfig/12.4/en-us/UserTsconfig/Options.html
PHP-based rendering seems to take all headers into account:

https://docs.typo3.org/m/typo3/reference-tsconfig/main/en-us/UserTsconfig/Options.html
MInd the additional "Properties" anchor in the last example.
Code snippet that reproduces the problem
Properties
==========
.. contents::
:depth: 2
:local:
additionalPreviewLanguages
--------------------------
some text
alertPopups
-----------
another text
should not render "Properties"
Expected output
- additionalPreviewLanguages
- alertPopups