Why does the music resume after removing one earbud when using the Xiaomi Buds 5?

The earbuds use sensors located in the upper and lower parts of the ear cavity to detect whether they are being worn. If your finger or palm covers these sensor areas when you remove the earbud, it simulates wearing the earbud and triggers the music to resume playing.