I'm trying to understand why in a ring we choose the names unit to an invertible element and irreducible element in this definition
Maybe historical reasons?
For example, I suppose the second definition are named as prime elements because of the analogy to prime numbers.
Thanks in advance.

Firstly, units behave "like $1$", which explains their name.
Historically, prime nuumbers were rather defined as what is here called irreducible. And for integers, "irreducible" and "prime" coincide. So for the general ring theory, where they do not coincide in general, one had to coin at least one new name. Since irreducible was established for (the ring of) polynomials and this well matches the notion that these elements cannot be (nontrivially) split into several factors, the name prime could be used for the other notion. (Alternatively, one would have had to coin a name for if-it-divides-a-product-it-divides-a-factor numbers)