The correct option is
A Not only did Ram attend the wedding, but his friend, Rahim also did.
The conjunction, 'Not only.. but also' is called a correlative conjunction which combines two grammatically equal items. This means that the words following both parts (i.e 'not only' as well as 'but also') should belong to the same parts of speech. Using different parts of the speech after 'not only' and 'but also' makes the sentence imbalanced and grammatically incorrect.
Option A: When a sentence begins with 'not only, it is followed by an auxiliary verb like 'did'/does'/'is' + subject. In this option, the sentence begins with 'Not Only'. This is immediately followed by 'did' (auxiliary verb) and Ram (subject). Hence, this option is correct.
Option B: The phrase, 'not only' is followed by 'attended'' which is a verb. However, the phrase 'but also' is followed by 'his friend, Rahim', which is a noun phrase. Hence, this option is grammatically incorrect.
Option C: When a sentence begins with 'not only, it is followed by an auxiliary verb like 'did'/does'/'is' + subject. In this option, the sentence begins with 'Not Only'. However, it is not immediately followed by an auxiliary verb. Hence, this option is grammatically incorrect.
Option D is incorrect as option A is the correct answer.