Being a tourist you will receive a Visa on arrival for 30 days upon arrival. Since August 2014 you can even extend your stay for another 30 days at ฿1900 without having to leave the country. Until then you could only extent for another 7 days or you would have to do the famous Visa Run.
If you plan to study at any eligible Institute, School or University in Thailand you would need to apply for a Non Immigrant ED Visa. This could be done at the local Thai Embassy or Consulate before traveling to Thailand or within the country if one would have at least 3 to 4 weeks left before one’s Visa expires. Here are the steps to go:
Step One: Application at School, Institute or University in Thailand
Register with the school of your choice that supports ED Visa applications
Step Two: Sending your documents in and make a down payment
The school would need some documents which you could email to them, such as a copy of your passport, a photograph, CV, depree etc. You will be asked to make a down payment.
Step Three: Receive Visa application documents
The school will send you the Visa application supporting documents
Step Four: Non Immigrant ED Visa Application
Apply for a Non Immigrant ED Visa, This could be done at any Royal Thai Embassy inside or outside Thailand. You may choose a Single Entry (€55) or a Multiple Entry Visa (€140). If you choose Single Entry Visa and you might have to leave Thailand unexpectedly before your Visa expires you can get a Re-Entry Permit ฿1000 at any Immigration office before you leave Thailand. If you have been granted a VISA, it will be stamped into your passport. The Visa will have an issue date. From this date on three month validity will start counting. Means during that three month you would travel to Thailand, start your studies and extend your Visa in Thailand before it expires.
I guess the purpose of the multiple entry Visa is get get in and out as much as you like but please check with Immigration first.
Your Visa will be valid for three month and you will have to extend it at the local Immigration office for another three month. After the second extension you your ED Visa will be extended for 6 month. During the entire period you will not have to leave Thailand at all.
Read more about the first and second extension here.