yes, but by getting the visa first in home country makes it way way easier to get a bank account based on long term visa once arrived.
Apply in country is harder as its very hard to get bank account without first having the visa. And you would need thai bank account to apply visa in Thailand