There are several rules that control the nature of the doubled sound. Different forms will have some subtleties to them, but let's go over the general rules now. For the sake of illustration, some of the examples below may use verb roots that you have not seen before. Do not worry; we will study these roots later on.
General rules for forming the doubled sound
Long vowels become short.
दा → ददा
dā → dadā
The intuition for this change is that the doubled sound should be noticeable without taking too much effort.
Aspirated letters become unaspirated.
धा → दधा
dhā → dadhā
See above. It is not difficult to pronounce two aspirated letters in a row, but it is easier to leave the first one unaspirated.
Letters from kavarga shift to cavarga. h becomes j.
घुष् → जुघुष्
ghuṣ → jughuṣ
हु → जुहु
hu → juhu
This change ultimately occurs for historical reasons. But it has the nice side-effect of making the result easy to pronounce.
If the root starts with two consonants, only the first one appears. But if the first consonant is an "s"-sound and the second consonant is unvoiced, then only the second sound appears.
क्री → चिक्री
krī → cikrī
स्था → तस्था
sthā → tasthā
स्मृ → सस्मृ
smṛ → sasmṛ
e becomes i. ai and o become a.
सेव् → सिषेव्
sev → siṣev
गै → जगै
gai → jagai
This change makes the doubled sound easier to pronounce.