From a personal experience, moaning means you are having a good time...having sex. So, there you have it. Moaning usually comes from having sex passionately.
A moaning type of sound can also be made by snoring. But the primary sound of snoring occurs when you inhale. Groaning occurs when you exhale. Some people can make a harsh, shrill, creaking sound when they breathe
this might help but I don’t exactly know what happens when you moan