I have a query in this. How “they” refers to only stars but not planets?
B is the correct answer.
Often, a pronoun which acts as the subject of a clause refers to the noun which acts as a subject of the previous clause.
A good rule of thumb would be to look at the options. If no options sort out the pronoun issue by replacing it with the relevant noun, just forget about pronoun ambiguity. If there are options that clarify the pronoun issue by replacing it with the relevant noun, consider all other grammatical issues first and then finally zero in on pronoun ambiguity
Here “Like the planets” is a modifying phrase. “The stars are in motion” is an independent clause. The pronoun “they” in the part after comma refers to the subject “stars” of the preceding clause.