I failed to get into the university I applied for.

I managed to get into the school I had applied to.

I read these two sentences. Why do they use different prepositions? please explain this to me thank you.
They vary because the university can be considered either the goal or the agent:

I applied to the government for my passport.
I don't think I have seen the first used. More commonly:

apply to a school or university

apply for a job

why? I don't know.
 Mister Micawber's reply was promoted to an answer.