I think we need to distinguish several issues here, which have been confounded.
(a) The OP has stated that in Italy a student is not allowed to enroll in courses outside of his major. This is far different from US practice, in which a student generally can enroll in a course offerred by any department, assuming the student satisfies the prerequisites. There are some exceptions with courses offerred as part of specialized programs, and enrollment in these courses is restricted to students in the specialized programs.
(b) So fresh_42 has suggested that the student just attend these other classes anyway. In the US, this is referred to as "auditing" a class. You attend the classes without officially enrolling (usually, if it's a small class rather than a large lecture, as a matter of courtesy, you would ask permission of the professor). This is fine, if you wish to learn the material for your own interest and development.
(c) But when you audit a class, your homework (should you choose to do it) is not graded, and you do not take the exams. Since you are not officially enrolled, you do not receive course credit, and the course does not appear on your transcript.