One country that used to have the religion on its national ID card until quite recently (the law changed in 2000, new ID cards without religion were issued from 2005 on) is Greece. So, does this happen in other countries? Yes, it does.
Having religion mentioned on one's ID card enables a government (or a religious organisation) to discriminate between people when allowing them access to services, positions or benefits.
If I only want members of religion X in my government (or, on the contrary, I specifically do not want them), selecting them based on their ID is a lot easier than having to find out their religion in other ways.
One example of such identification in the extreme was of course the visual identification of Jews in Nazi-Germany, where that visible identification greatly simplified the implementation of laws banning Jews from jobs, benefits, et cetera.
It is highly unlikely that official organisations or governments will readily admit to such motives, of course, but it seems they are sometimes trying very hard to hang on to at least the possibility to control people this way. The Orthodox church in Greece protested loudly against the removal of religion from the ID-card, and yet I cannot find any rational argument supporting their actions other than trying to hang on to the privileged position of that church and its followers in the Greek state - effectively hanging on to the ability to treat non Christian Orthodox citizens as lesser citizens.