Some universities have admission criteria you need to meet for some courses, some don't. These are usually called Numerus Clausus, short NC. It's calculated based on your Abitur-grade, and the time you waited between school and university. Basically if you have good enough grades you can get enrolled immediately, if your grades aren't sufficient you'll have to wait a few years until you can start.
Technically, that's not what the NC is, at least not in my state. How it works is this:
There is a limited amount of people that can enrol into a course of studies, because of limited (staff and room) capacities. So you usually have more people applying than can enrole, but that's not too bad, since they are applying to multiple universities, and probably won't go to yours.
When a student applies, they get put on a list, which is sorted based on their marks and a few other factors (for example, if they applied before and were told to wait.) The people on top of the list are the first to be accepted.
The faculty knows it can accomodate X students. It also knows that when it sends out acceptance letters, only some fraction of the accepted applicants actually enrols, because they also get acceptance letters from other universities. So in that knowledge, they send out many more acceptance letters than they can actually accomodate, e.g. 4 times as many. (This factor is called the "overbooking factor" (Überbuchungsfaktor) and is decided some time in advance by the faculty based on experiences from previous years.) So if your list of applicants is 1000 people, and you can only accomdate 200, with an overbooking factor of 4, you send out acceptance letters to the top 800 people on the list, because you know most of them will enrole somewhere else.
Ideally, these effects cancel each other out. Let's say it's even more than that. For some reason, only 100 of those 800 students enrole, but you want to fill the spots, so you keep sending out acceptance letters to people further down the list, and so on.
It works out remarkably well, actually... usually.
(I'd be curious to know if this process is similar in other countries.)
The NC then is simply the average mark of the "worst" person, marks-wise, who got in. It serves merely as an orientation value for potential applicants. Sadly, most take this to mean "you HAVE to be this good to get in", which is simply not true.
Most universities in Germany don't have a NC for Computer Science, mine doesn't either, but Loki goes to a university which has a NC.
Yes, but it didn't when I enrolled
In fact, we only have one because we were forced to from somewhere higher up the administration chain. So we put in a suitably high overbooking factor. What happened last time was that people were so intimidated by the new NC that few applied, so literally everyone who applied got in, and the worst of them had a 3.8 as the average, simply because nobody worse dared apply
(The worst you can pass the Abitur with is a 4.)
Re "deciding at grade 4 where you go": yes. This is one of the biggest criticisms of our education system. Technically, you can switch schools midway, from Hauptschule to Realschule and then to Gymnasium, but this rarely happens.
Dunno if it's just my state*, but we also have a "Gesamtschule" ("common school") where you can go instead of any of the three, and theoretically(tm) you'll get the same education as on a Realschule, sufficient to continue your way in a Gymnasium to an Abitur. Practically... yeah.
*While federal law affects much more here than in the US, education is a matter of the individual states. Most states have roughly the same education model, though. Except Bavaria, who is a special snowflake, as always.