There are two 7 year rules -- similar but by different agencies. Both are in regards to the USMLE:
The ECFMG requires that you take no more than 7 years from your first step exam to your last, including ONLY Step 1, 2 CK, and 2 CS. If you take longer than 7 years, then you need to retake steps to get them within 7 years. If you are not ECFMG certified, you cannot do any residency in the US.
Many (but not all) state licensing boards have a 7 year rule. That one requires that you take all steps (USMLE 1, 2CK, 2CS, and Step 3) within 7 years to get a license. This can cause PD's not to take you, because in some states you need to get a full license for your PGY-3. Also, some will not take you because they don't want to train someone who will not be licensable in many states.
Similar but unrelated, many programs have unofficial cutoffs of how "old" (defined as how far from graduation, not chronological age) they allow applicants to be. Some programs will not consider grads more than 3 or 5 years from graduation.