I'm learning music theory on my own and thus, I encounter some difficulties in understanding them.This is one of those difficulties.What do those notes (circled in red) mean as each of them has different values? How should I play them on the piano? How are they related with tempo?
Here's another way to view it which might help. Imagine that the music is being by four instruments or voices which can only play one note at a time. Maybe a string quartet or four singers (SATB). Let's imagine a string quartet: violin 1, violin 2, viola, and cello. Each has a part with just one line of your music.
Violin 1 has the tune: the top line and plays those short notes.
Violin 2 and the viola have long notes. The first for each lasting the whole first two bars.
The cello plays single beat notes.
Now, back to the piano: you need to replicate that effect by yourself. So, as Tim says, you need to hold the initial E and B in the right hand for two bars with two fingers while the remaining fingers play the tune. Sometimes, you can use the right pedal to get the held effect without actually holding down the notes but not in this case as it would mess up the top line.
It's in 3/4, and those notes on the treble clef with the tails going down are held for each full bar - all three beats (dotted minims). And because they're also tied to the same notes in the next bar, they get held on for another three beats - six in all.
So while you hold those keys down with thumb and index or middle finger, the other fingers of r.h. are playing the tails up notes, the first of which (a very short note duration) is played at the same time as the dotted minims.
In general, these notes with the stems facing the other direction indicated that it's a >second voice<
If you have any notation program, just look up how you can change a voice from voice 1 to voice two. This example above is what you will get.
It basically just means, that you have to see both voices as an independent (melody) line. Sometimes you're able to play the second voice as well and it's just written like that to make it look easier on paper for you. If you would write it in just one voice, you would get way too many unnecessary ties and it would look like this:
In this case you would hold down the B and E two full bars with your thumb and index finger, while playing the top line with your other three fingers for example.
Sometimes these lines are written for multiple players, like a piano duo. In this case Piano 1 would play the top line (Voice one) and Piano two the second one (Voice two).