It's not particularly the prepositions. It is when the period of time began and to when it extends.
I have been watching television.This is an activity that began in the past and continued up to the present moment.
I have been watching television for two hours. The activity began two hours ago, and is probably still going on now.
I had been watching television. This is an activity that began before a certain past time and continued up to that past time
I had been watching television for two hours. The activity began two hours before the time we are talking about, and was probably still going on at that time.
I was watching television at 10 o'clock last night. The activity began before 10 o'clock and was still going on at 10 o'clock.
I was watchingtelevision last night. We are not particularly concerned with the beginning or end of the activity, simply that it happened.