Which Espressif32 Platform versions do you have installed right now?
If you use platform = espressif32 without fixing it to a specific platform version, the version with the highest version number will be picked by platformio.
I am a bit confused about your Arduino version “2.3.5”. There never was such an Espressif Arduino version. The latest 2.x version was 2.0.17 (platform-espressif32 6.8.0 - 6.10.0) - See this list
There also was no Espressif Arduino version which based on ESP-IDF 5.2 (see the list above).
Did you install pioarduino to get the latest Espressif Arduino core (3.x) ?
If so, this version will be picked up by platformio as it has the highest version number. The change from 2.x to 3.x comes with a lot of API changes which breaks existing code - See Migration from 2.x to 3.0 - - — Arduino ESP32 latest documentation
If you want to go back to a specific version, simply change the platform setting in your platformio.ini
Example, to get Espressif Arduino 2.0.9 based on ESP-IDF 4.4.4: platform = espressif32 @ 6.3.2