I'm not sure I completely understand the original question. I think it was "Could Trump stay in office for a third term by declaring martial law?"
Going back to the basics, the person declaring martial law must have legal authority to do so. An ex president is a private citizen with no authority to declare martial law or maintain martial law.
Martial law is the suspension of existing laws. It is not a mechanism to create new law out of thin air. I see no legal mechanism to "boot strap" a suspension of laws while president into a new law that, contrary to the Constitution, allows a person to continue to be president. An ex president could of course assert such power, but to my mind it would be no different (legally) than a random dog catcher from Cleveland asserting that he is president and ordering the military to follow his orders.
Getting back to your questions:
"Does the constitution prevent elections if Martial Law is declared?" I'm not a constitutional law scholar by any means, but I think the short answer is "no." A related question is "Does the constitution allow a president to prevent an election by declaring martial law?" I think the short answer is again "no" but it's conceivable that a president might successfully prevent an election if the military went along with it.
"Can congress declare martial law invalid if no legitimate reason is present? Do they have such powers?" I think the short answer is "no" if "declare" means a legally enforceable declaration (congress frequently makes declartions to send a message, but these do not have the force of law). Congress could pass a law restricting the president, but of course the president could veto it. Laws restricting the executive branch tend to be weak and open to challenge for a variety of reasons.
It seems to me that a more likely scenario would be for congress to directly invoke (or threaten to invoke) its constitutional power and impeach the president, remove him from office, and declare him disqualified to hold office in the future. Theoretically, there is an issue if it's not clear that the person being impeached is in fact legally the president or just a prior president. It's probably a moot point because an ex president would have to assert he is no longer president to "win" on this basis, which means he'd still lose.
Take the above with a grain of salt. These are just my initial impressions.