I was wondering what is the rule for the spelling of words that contain double consonants?

For example:

Do I spell the word "recommended" with two Ms or just one? (I am aware that its one M, but why?).

Most of the time you can sound out a word to figure out a repeated consonant or vowel or you can target the syllables. However, since the English language is not a one-to-one phonetic language, then not every scenario is accurate.

What's the golden rule?

Many Thanks.
MatskoI am aware that its one M
No. It's two m's.
There is no general rule.
panel has one n. flannel has two n's. These rhyming words should both take the same pattern!
The least often doubled are h, j, k, q, v, w, x, y. It would be a rare word that contained a doubling of one of these consonants.
In the case of Latinate verbs, doubling is a little more predictable. Many of these consist of a prefix (or two) and a root. Unfortunately, you have to have a good knowledge, or at least a good intuition, about Latin prefixes and roots. All in all, it is probably not worth the trouble to learn all the rules.
Nevertheless, it may be instructive to examine a few cases.
Prefixes: re, com. Root: mend. recommend You need one m for the prefix com and another m for the root mend.
Prefixes: de, con. Root: struct. deconstruct No doubling required.
Prefixes: dis, con Root: nect disconnect One n for the prefix; another n for the root.
Prefix: op Root: pose oppose One p for the prefix; another p for the root.

Prefix: im Root: merse immerse One m for the prefix; another for the root.

Prefixes: ac, com Root: mod Suffix: ate accommodate One c for the first prefix; one for the next prefix. One m for the second prefix; another for the root.

Watch for these related groups of prefixes that are associated with doubled consonants:
col, cor, com, con; il, ir, im; op, oc, of; sup, suf; ac, af, ag, al, an, ap, ar, as, at
collect, correct, commend, connect, illegal, irregular, immerse, oppose, occur, offer, suppose, suffer, accede, affect, aggregate, allay, announce, approve, arrange, assault, attract.
There is no prefix am or om before m. These are reduced to a and o, so there is no doubling: amend, omit. The same applies to av and ov. avoid, overt.
Don't confuse the Latinate ac, af, ag, etc. with the "native English" prefix a, which connects with "native English" roots: awake, asleep, ago, awry, about, around, aloud, ... These never have doubling.
These comments just give a rough idea of a few of the sorts of ideas that underlie the patterns of doubled consonants in English.