1. used for saying that someone or something is responsible for something good that happened.
Thanks to this treatment, her condition has improved.
2. used for saying that you blame someone or something for something bad that happened.
The railway system is in chaos, thanks to the government's incompetence.