In the United States, there are a number of statutes that prohibit the collection of various pieces of information (e.g. sexual orientation) for certain purposes or by certain actors. But it is not prohibited in the general sense for all actors, nor is it illegal for a person to disclose that information voluntarily.
The types of protected information are known in the United States as protected, or 'suspect' classes. Not all of them are prohibited (e.g. nation of origin), because there are corner cases where the collection of such data is actually mandated by other portions of the law - but the collection of such data automatically arouses suspicion as to the motive behind the effort - hence the term 'suspect class.'
Per comments, here are some examples:
1964 Civil Rights Act
(i) a complaining party demonstrates that a respondent uses a particular employment practice that causes a disparate impact on the basis of race, color, religion, sex, or national origin and the respondent fails to demonstrate that the challenged practice is job related for the position in question and consistent with business necessity; or
Asking a question on a job application or as part of an interview process constitutes an 'employment practice' in this context, and thus - unless there's a legitimate business reason to ask the question - it's a simple matter of statistics to show that asking the question creates the effect. Elsewhere in the same statute the excuse that, e.g. race wasn't the sole factor is pre-empted: if it can be shown that (e.g.) race was considered at all then the whole practice is unlawful.
Similarly the ADA (as amended in 1990) explicitly prohibits employers from asking questions likely to reveal a disability status (again, except where actual job performance concerns are at issue) (emphasis added):
§ 1630.13 Prohibited medical examinations and inquiries.
(a) Pre-employment examination or inquiry. Except as permitted by § 1630.14, it is unlawful for a covered entity to conduct a medical examination of an applicant or to make inquiries as to whether an applicant is an individual with a disability or as to the nature or severity of such disability.
I expect that you'll find similar provisions in a number of other nations to a lesser or greater degree.