Depends on the country, many countries accept that you enter and leave on different passports, but some dont. For example, if you travel between the EU and Africa and have dual EU/African passports, which is very common among the African diaspora in Europe, you basically have to use the EU passport to travel to the EU. The alternative would be to go through the time consuming and very bureaucratic process to get a Schengen visa - that doesnt make sense at all if you have an EU passport.
Likewise when travelling to Africa, you are going to use your African passport, as most African countries have visa requirements for EU citizens, while not as paperwork-intensive as Schengen requirement, they can be capricious and random. At check in in the EU, you just show the African passport and no need for extra paperwork. Likewise on arrival in Africa, it s a much smoother experience travelling in on the local country's passport than on a foreign one.
EU countries typically never have a problem with people leaving on their other passport (as long as they were in the EU legally) - there is no side room issues. I know people who have travelled like this for 30 years without any problems.