For example, Saudia Arabia is wealthy and extremely religious... I hope I don't have to explain the counfounding factor in this case.
Regarding the USA: even though it scores high in religious people rates, it's also one of the free-est places in the world, so people who are not believers are still relatively free to go about their daily lives without problem, unlike in most other highly religious nations. The USA also happens to have the biggest military in the world, capable of taking over and applying pressure on its enemies in order to further its economical interests... I think these two factors should be sufficient to explain quite well why the USA is an exception to the rule.
In Europe this is absolutely not a thing. Well, unless you want to work at a religious organisation I guess.
A and B here are religion and wealth/technology I understand (sort of) the points you are making about wealth, but how does any of this stuff link causally with religion?
One can read this as "religion causes people to be poor", but that's not exactly the same because when a whole country is religious, its institutions and codes will tend to be based on religion rather than science or a rationalist moral system.
With this, I hope I am making it clear that saying that religion can cause a country to be poorer than it could be otherwise is not the same as saying the same about a specific person or family.
Now, we have an extremely simplistic formula based on this hypothesis: the more religious a country's population is, the poorer the country should be.
But many factors can influence a country's wealth, including its military power (which could be a result of its priorities, not necessarily of its wealth in the first place), how much its culture/religion incentivate creativity and support new ideas (things which tend to improve technological advances which usually translate into wealth), how many natural resources it was blessed with, how honest the population is in general and so on. These are all confounding factors (they may affect the results) which can cause some countries to deviate from our original hypothesis... in a canonical scientific experiment, to know if the hypothesis is correct, you would need to find ways to remove these factors from the equation so that the only important factors that matter are those you include in your hypothesis. That can't be easily done for a study of countries because there's just not enough of them.
So the best we can do is see how well most countries fit into our hypothesis and try to understand the most important (confounding) factors that can cause countries to deviate from our hypothesis to see if the outliers can be explained away (or if they show a genuine weakness in the hypothesis) so that we can have a higher level of confidence that the hypothesis seems correct.