Stimming is something familiar you do to give yourself a simple sensory stimulation that you can focus on, to help you regulate your sensory data when you have too much or not enough, and to help regulate or perhaps process your emotions.
The practice of stimming is not an exclusively autistic trait (some socially accepted stims are performed regularly by allistics), but it has a special place for autistic individuals; it can help block out the onslaught of raw sensory input that allistic people naturally filter down to a manageable level, allowing you to somewhat ignore the chaotic stimuli of your surroundings and instead focus on something predictable, ordered, and repetitive, which you have control over.
It can help calm you down. I've certainly noticed I start rocking my shoulders more when reading something uncomfortable, e.g. glancing at hate speech against a minority group I'm in. (Would that the daily news wasn't filled with such things right now, in 2020s Britain.)
There seem to be two different types of stimming, an unconscious one that everyone agrees is definitely stimming, and a conscious equivalent that some but not all people also see as a form of stimming. I don't know of any terms for these distinctions, so let's call them unconscious stimming and conscious stimming.
If you're Autistic and don't stim (or don't notice yourself stimming very often), you might have learned to repress your stims at a young age, and you might find it helpful to spend some time consciously stimming by playing with movement and trying out different stims to see what feels good to you. Finding the ways your body likes to move and allowing stims to develop may help you feel more in tune with your body, calmer and less stressed.
Unconscious stimming, for want of an official term, is what most people think of when you talk about stimming. It's not something you have any control over, it's something you suddenly notice you've been doing for the last few seconds.
You shouldn't suppress the urge to stim. Stimming performs a vital function, helping regulate your mood. *Some* stims might be unhealthy, in which case you can practice healthier equivalents to show your unconscious that these are other available options. But you can't stop stimming altogether, and shouldn't feel pressured to try. Stimming in general is a perfectly healthy thing that autistic people need to do, and as long as it isn't harming anyone, it shouldn't be discouraged. It's nothing to be ashamed of.
In a society consisting solely of autistic people, it would simply be accepted that this is how everyone regulates their emotions, and no-one would think anything of it. Whether allistic people feel the same way is on them.
Next, let's get a little bit controversial.
Conscious stimming, for want of a better phrase, is when you decide to give yourself some known, orderly sensory data you can concentrate on in order to block out the chaotic sensory data of the outside world.
You might choose to listen to a song you like on repeat, or calm down to some ambient music, or concentrate on a complex task while drowning out the world with a field recording.
After a stressful day, you might let off steam by jumping on a trampoline, or practicing a martial art, to help regulate your emotions.
These may or may not count as a type of stimming, I'm not sure, and no-one I've asked seems to be sure either. It might be more accurate to say that these are things that reduce the need for stimming, rather than a separate form of stimming in their own right.
Any injury from stimming is non-intentional and accidental! Stimming is often an autistic person's body's attempt to manage sensory input, rather than any attempt to cause harm or injury.
If a stim is harmful, please consider trying to change to a non-harmful stim. Trying out stims of the same type (for instance chewing chewing-gum or chewlery instead of your lips) is more likely to replace the harmful stim. If harmful stims only happen during meltdowns, trying to change the stims yourself is not likely to work. In this case, it is better to take preventative measures.
Preventative measures are often avoiding high-stress places as much as possible, wearing headphones to mute sound, etc. There are (or will be) articles for the senses that will include ways to manage in an unfriendly (to the senses) world.