Tension by a string on a pulley

I was doing this problem, and I had trouble drawing the free body diagram of the pulley.

(The pulley is massless, frictionless.)

I had trouble understanding how both the ends of the string will apply a tension $$T$$ along the string on the pulley, and also, why doesn't the string that is in contact with the pulley apply either a contact force (as the string and the pulley are in contact), or a tension force (as the string is stretched)?

If I just assumed that this is how the string applies tension on the pulley, I was able to solve the problem, but I fail to understand why this is the case.

PS:While this is technically a homework problem, I did this problem, but just had a doubt in drawing the free body diagram of the pulley.