ELI5: how do mobile devices know your movements? - eviltoast

I’m primarily talking about stuff like step counters, but also health apps measuring your heart rate, how many stairs you take, the length of your steps, and so on. I’m honest when you tell me to explain it to me like I’m five years old, this one boggles my mind.