Don't touch other people without their explicit knowledge and permission. When in doubt, always ask first. If someone says they don't want to be touched, respect this.
This is especially important when it comes to strangers and acquaintances, and especially in situations where there's a power dynamic, such as an adult asking before hugging a child, or even an older child such as an older sibling or older cousin asking before hugging or touching a younger child.
This is important for making the world a kinder place for those with trauma or neurodivergent people, because a lot of forms of trauma and neurodivergence make it extra disturbing and unpleasant to be touched without consent. Or even if someone isn't traumatized or neurodivergent, it's still fair to not want to be touched and to have that boundary respected.
It's also important for teaching kids boundaries and consent from a young age.
This applies to all situations, even situations many may think are an exception, such as if someone is pregnant. Often people will think it's acceptable to approach a pregnant stranger in public and just touch their stomach without permission. However, someone can be pregnant AND traumatized or neurodivergent. Or even if they're not traumatized or neurodivergent, it's still normal to find it uncomfortable for a total stranger to walk up to you in a grocery store and just put their hand on your stomach without asking. Contrary to popular belief, being pregnant doesn't make this any less weird.
Of course as you get to know someone you'll get more familial with what their boundaries are and how comfortable they are with being touched. But when in doubt, just ask.
This is great advice and I'd like to add that you should always treat mobility aids/assistive devices for disabled people as a part of their body. Do not ever touch someone's cane or wheelchair without asking. Especially not a stranger in a public space. Having someone move your wheelchair without asking is like if someone came up behind you in the store and grabbed you by the arms to physically move you out of their way.
It's disrespectful of their autonomy, their personal space, and their right to take up space in public. They have just as much right to be where they are as you do - more if they were there first, in fact. If you need something and someone is in the way, with or without a mobility aid, just say, "excuse me, can I get behind you/past you" or something. If it's not urgent and they don't seem to be idling there forever, it's even better to just be patient and wait a moment for them to move of their own accord