The designations are given out at the time of design and they are given out in order. The reason why there are gaps at times is because some cars don't make it to market, at all.
Take a look back at the mid 90s and forward and it is a lot easier to see. Also, you can tell when a car was under development for a long time because it has a relatively low 'E' number compared to what else is on the market from BMW.
Case and point, from this link
https://www.turnermotorsport.com/t-BMW-Chassis-Codes you can see that the original 8 series was given the E31 code. It was produced from 1990-1998. However, it was probably in the design phase for a very long time through the early 80s.
The E30 hit production in 1984, so I am gonna guess that the E31 started design around 1982, even though it didn't come to market until 1990.