Is it better to write a thesis statement before or after looking for the sources?
Yes, of course. You research a topic first. Then, you can come up with a claim on it.
Thinking on a thesis statement and then looking for a literature to support it, you risk
– to waste a lot of time (eventually, you may change your mind and will have to rewrite the statement)
– to use sources, which are not so good (you actually agree to articles that argue what you want them to instead of looking for quality articles in the first place).
What is more, a thesis statement has to demonstrate supporting points, so you can create a good thesis statement only when you know what supporting information you can cite.
You my read more about how to create a thesis statement and how it guides the rest of an essay in this post on my blog