The UK operates a points-based immigration system underpinned by the principle of visa sponsorship. A Tier 4 visa is issued to study in the UK. The sponsor for Tier 4 purposes is the educational institution where the student will study. The visa is issued for a particular course at the institution.
You must apply for a Tier 4 visa prior to travelling to the UK unless you are already in the UK holding a valid visa that permits you to make an application for further leave to remain under Tier 4.
You should apply for your Tier 4 visa in your country of nationality or country of residence (where you have permission to live).