Typically you'll pay 6-8% to sell a house. It can vary by region, but in many areas the convention is for the seller to pay both buyer's and seller's realtor fees (commission) and there are other costs associated with buying/selling. This factor drives a lot of the conventional wisdom about needing to stay in a house for at least 'x' years. If you sell immediately, you'll lose money because of the costs of buying/selling.
The other factors are that more of your early mortgage payments go to interest than to principal, and that home prices vary over time.
7 years is a bit longer than I typically hear, let's say you put $10,000 down on an $80,000 apartment at 4% interest and 30-year term, you can use an amortization/mortgage calculator to see how this shakes out:

So after 3 years (36 payments) your $70,000 balance has been reduced to $66,149. If you sell for $80,000 after 3 years and it costs you 8% to sell, then you'll get $7,451 after the mortgage is paid off: (80,000 * 0.92)-66,149
. Since you put down $10,000 you've lost money on the sale. After 7 years (84 payments) selling at $80,000 and paying 8% to sell you'd end up with $13,359, putting you a bit ahead of your down payment.
However, that approach is a bit too simplistic because you'd have been renting if you hadn't owned, so a more comprehensive analysis would compare the total cost of shelter over the time period which can be hard to estimate. Also, if didn't buy you could invest your down payment, so would want to factor in expected return on that. The apartment likely has some sort of monthly fee (HOA or otherwise) and there's maintenance/repairs to consider. Also, the price of the apartment will likely change over the years, if it's not in a good area it could lose value, hard to predict.
I suggest researching rent vs buy calculators to help assess the area you're looking at as well as market projections. I've heard 3-5 years used more frequently than 7 as minimum time before moving, but those rules are too simple to be very effective.
Also, if buying an apartment/condo/townhouse, find out what is covered by your building's/association's monthly fee and what is not, and find out what their reserves are. If the reserves are too low, they will need extra money (special assessments) from all owners in the complex to cover major repairs.