If you are going to live in purpose built student accommodation, often called Halls of Residence you should book this before you travel.
If you are planning on living in private rented accommodation, you are advised to book this after you have arrived, so you can view the property in-person and have time to read and understand the contractual obligations. However, this may mean you need to stay in temporary accommodation until you have found somewhere to live. Temporary accommodation is limited and often means staying in a hotel or guest house, both can be expensive options.