What you're looking at is two separate voices. In more complicated music, we sometimes write out two independent lines (or voices) on a single stave.
The first voice in this piece comprises the crotchet rest, followed by the quavers C+G, C+G tied to another C+G, then C, D and D again. This adds up to four crotchets.
The second voice comprises the quaver rest, the dotted crotchet E, the crotchet E, the quaver rest, and the G+E quaver that is tied into the next bar. This also adds up to four crotchets.
There is only a single voice on the bass stave.
The reason I know this, is because of the direction of the note stems. See how the first voice only has stems that point upwards? The second voice all points downwards. I know which rests to associate with each voice through the vertical positioning of the rests on the stave, and also because there's only one interpretation which will allow the bar to add up.