Checking this list, I have noticed that the vast majority of countries do not limit mayors terms count. However, the president is usually limited to two terms of 4-5 years.
To narrow the question scope, I will take the particular example of my native country, Romania: ex-communist country, parliamentary democracy within the European Union. However, I think the following reasoning can be applied to many other developing countries as well:
relatively high corruption levels (source) clearly helps mayors to maintain their power, as they (directly or not) control much of the economy within the town they lead
parliamentary or presidential elections disruption - mayors of medium and small towns or villages can easily influence voting by using local resources to promote friendly candidates. In the country side this done through relations with some other public figures such as priests or medical doctors.
one round-system for voting for mayors as opposed to Two-round one (might be Romania specific) clearly favored existing mayors. This has practically rendered mayor election useless (most of existing mayors have won an extra term)
The bias towards having the same mayors is so big that some mayors were in jail when they were elected.
Question: considering all above, why can mayors be elected for more than the typically two terms? (while presidents can not)