Why Do Pretrained Language Models Help in Downstream Tasks? An Analysis of Head and Prompt Tuning