In giving a guess on why certain of his affirmations seem to have been successful, Scott Adams says (How to Fail at Almost Everything and Still Win Big, 2013)
I think a deep and consistent focus on what you want is all that is required.
The idea is that affirmations – repeatedly focusing on a sentence such as ‘I am a world famous cartoonist’ (one of Adams’ own examples) – causes or is correlated with a deep and consistent focus thereof, which in turn helps to create the outcome.
One thing I find interesting about this is that a deep and consistent focus is in this context more-or-less a deep and consistent belief, which is a key part of faith-in-prayer. The point isn’t to ‘repeat words vainly’, but to go into your ‘inner chamber’ and pray there.
In this sense, it seems things like affirmations are a kind of secular prayer. Like certain kinds of prayer, they are used because they seem to work, whatever mechanisms might be in operation.
Indeed, affirmations seem to have entered secular culture from Christianity (in particular, New Thought Christianity).