For example, you pray Isha, then after midnight before going to sleep you perform the sunnah for Fajr, instead of sleeping, waking up, and doing it right before Fajr.
The time for Fajr is from dawn to before sunrise, no prayer - fard or sunnah - can be offered before its time. Actually its an illogical question to ask if sunnah of Fajr can be done at midnight, since praying sunnah means copying the way of the Prophet. How can you be following the sunnah of the Prophet if you pray at other than the time he prayed it? Fajr means daybreak, how can you be doing the daybreak prayers at midnight?
Ibn Qudaamah said in al-Mughni (2/544)
The time for every Sunnah prayer that comes before a fard prayer lasts from when the time for that fard prayer begins until it is done. The time for every Sunnah prayer that comes after a fard prayer lasts from after the fard prayer is done until the time for that prayer ends. End quote.