Rav Nahman wrote that by trust in God, good thoughts are drawn to a person. [In Sefer HaMidot].
This is the usual approach of Rav Nahman --that is to find some human problem that someone is struggling with and to find an indirect solution. He is aware that human problems are is hard that a direct solution is impossible. So he looks and finds some side route approach it from.
For instance in our case, lots of people are struggling with wrong and or crazy thoughts. So instead of just advising "Do not think them." which can not work since the person is struggling anyway. So he finds an effective way that is indirectly related to the problem.
Same thing with sexual sin. The ten psalms [16, 32,41,42,58,77,90,105,137,150] are a way to correct something that does not have any simple solution.