I connected the sensor directly to the ESP32 and checked the SCL and SDA pins, which showed a voltage of 5V. My question is, why wasn't the ESP32 damaged by this 5V connection? I looked at the datasheet for the development board, but I couldn't find any level shifters or protection circuits.
Often, internal signal limiting circuits will offer enough protection for one to ‘get away with’ such abuses for short periods of time. It is, however, extremely unwise to depend on this to work indefinitely.
How you know that? Because magic smoke didn't puff out immediately?
Esp32 is quite robust and lot of people here are abusing those, but that doesn't mean they don't get damaged.
You should read and understand the datasheets for every component you use in your design.
What does the ESP32-S3 datasheet say about the maximum and recommended voltage on a GPIO?
I would use one of two ICs: the PCA9306 or the TXS0108E. The latest I²C specification defines a logic high as greater than or equal to 0.7 times the supply voltage, and a logic low as less than or equal to 0.3 times the supply voltage. For a 5V system, that means a high is 3.5V or above (0.7 × 5V), and a low is 1.5V or below (0.3 × 5V).
In the past the Logic level thresholds could vary between devices depending on the technology used to manufacture the chip, so it's important to verify compatibility when connecting different components.
Without knowing about your specific board I'm going to guess it has a 5V to 3.3v regulator on the AHT20 board. And likely the output of the sensor is 3.3v. This is a guess, it must be verified. If you have a multimeter (even a cheap one is recommend for a hobbyist) you can measure the voltage on the Chip of the AHT20.
And the level shifter you drew will not work. It is much too slow for I2C.