As others have said, different universities -- and even different programs within a university -- have different policies about when repeating a course is allowed and if so, how it counts towards the GPA.
Actually, it's even more complicated than this: the same student enrolled in the same program can have multiple GPA's! It is my understanding that at many if not most American universities, there is one GPA that is simply the average of the numerical scores (on a 4 point scale) over all courses one has taken. With respect to this system, if you take a course once and get an A and then again and get a C, then it does not go into your GPA as a 3.0; it goes in as a 4.0 and a 2.0. The average is the same, but the weight is twice as much, reflecting the fact that you completed two courses rather than just one. However, GPA "in your major" may be counted with a different weighting system.
You seem to think that there's something unfair about averaging the grades. To me, it sounds like a generous system: and in fact, I don't think that it is guaranteed that a student is allowed to repeat a course to improve their grade if the grade they got the first time around is considered "satisfactory". This practice again depends on the university and the program.
The student has exhibited an "A" level of "knowledge" so why penalize them.
Sorry, where is the penalty you speak of? They got a C and they got an A, and both are being recorded.
If the student attempted to learn on their own and did not attain "requisite" understanding prior to attending the course but ended doing very well in the course they would not be penalized.
Again, I don't see how anyone is being penalized. A low grade is not a penalty.
Or perhaps offer two measures of GPA, one as a summation of everything and one that only includes the students best performance for each course taken?
If you want to present this alternate calculation of your GPA to someone else, you can. But you also have to record the official GPA.
Finally, I think that the practice of allowing a student to take a course multiple times and only record the best grade is a poor one, for several reasons:
i) It is fundamentally not transparent. The standard unit of coursework in most American universities is the semester-long course. You are registered for a certain number of courses each semester, and you get grades for each of them. If grades get replaced by later grades, this kind of information is lost, and it may be that the student is recorded as taking nothing during that semester! This leads to:
ii) Because high course grade are very desirable, this practice would encourage students who got good but not optimal grades to repeat the course until they got the highest possible grade. If you think this through soberly for a while, you'll see it's just a bad idea. The whole point of a grade like a B is that it's good enough to move on to the next course. Students who repeat courses until they get A's could take much longer getting through the program. It will create a culture where most students who are taking the course the first time are taking it "for practice only". If courses were heavily populated with more advanced students who did well the first time around and are insisting on taking it again to get the highest possible grade, then that could seriously skew where the course is being pitched, which would encourage yet more students to repeat every course they take. Finally:
(iii) We do not want students to be able to graduate with a perfect GPA if they spend seven years in college instead of four. Moreover -- sorry to divulge the ugly truth -- we don't want a substantial percentage of college students to have the highest, or essentially the highest, possible GPA. While the competitive nature of GPAs in the current university environment has many unpleasant aspects, the vast majority of American culture is fully bought into it...especially including the students. If 50% of every class got a 4.0 GPA then most of the advantages of having such a high GPA would evaporate, and employers / graduate schools would hire you based on other metrics. (Note that people often talk about grade inflation, but really grade inflation is only a problem to those who are not familiar with the current university system. For everyone who is sufficiently informed, it doesn't matter whether the average grade in a course is a C or a B+. Still, after taking about 40 courses, there will be a small tail of students who have gotten almost all A's. So there is no problem here.)