In my head canon, Luna and Nightmare Moon are separate entities.



Just over 1,000 years ago, Nightmare Moon ruled over Equestria and exercised rule by iron hoof. Her sister, Princess Celestia II of the Crystal Empire, aided by rebel forces, deposed her and founded the Republic of Equestria.



About 1,000 years later, Nightmare Moon's contemporary supporters band together in protest of the government's inaction during a recession. This protesting escalates into rioting and all-out civil war. Nightmare Moon's disembodied spirit possesses Luna and attempts to gain power, but Celestia stops her and banishes the spirit to the moon. The spirit comes back in S1E1 and is banished again.