The grammar is “A (Clause) なんて B (Noun/Na-adjective) だ” meaning “it is B that A”. The A is a clause and the B is a noun or na-adjective. なんて indicates the preceding clause is surprising or unexpected and だ is only used with a noun or na-adjective, so if it’s an i-adjective such as 嬉しい meaning “happy”, just remove だ. 奇跡 meaning “a miracle” is a noun so だ should be attached. So it means “it is a miracle that 好きな人が自分を好きになってくれる”.
好き means “favourite” or “to like”. It’s a na-adjective so with the noun 人 meaning “a person”, you need な between them so 好きな人 means “favourite person” or “person I like”.
が emphasises the preceding word as well as marking the subject.
自分 means “me” which is more objective than 私.
The を particle indicates the direct object of the action 好きになってくれる.
なって is the te-form of the verb なる and a noun or na-adjective になる means “to become something“. If it’s an i-adjective, remove the に and change the い to くsuch as 嬉しくなる meaning “to become happy”. So 好きになる means “to become favourite”, “come to like” or “fall in love”.
And a verb te-form followed by くれる means “to do something for me“ which shows the speaker is the receiver of the action and the action is something beneficial or favourable to the speaker.
So 好きな人が自分を好きになってくれる means “A person I love falls in love with me” or “someone I love loves me back” and 好きな人が自分を好きになってくれるなんて奇跡だ means “it is a miracle that someone I love loves me back”.
と思った means “I thought that”. 思った is the past tense of the verb 思う meaning “to think” and the quotation particle と works like “that” in english.