Pretty normal to have passport check on exiting a country. You might have overstayed your visa and you are going to be fined or banned, or you might be a criminal and they will arrest you.
Problem is that nationals are usually not extradited for crimes done in other countries, even if it happens in shengen area. So each country better check who is leaving to get criminals / fines not paid / avoid child leaving with one divorced parent.