Hi. I'm in the end of the process of getting Spanish residence permit and I was︃ very interested in this question. I had two or three consultations with lawyers in Spain︄ asking this exact questions. They do not know. No kidding. Their position is "Sometimes tax︅ authorities decide that you are a tax resident and send you a letter. Then you︆ need to prove you are not, the proper way is tax residency certificate from other︇ country" They are not sure what triggers that letter, they are not sure what other︈ ways to proof non-residency. They give some meek (different) answers and the common motive is︉ "It just happens sometimes, not often, have tax residency certificate handy".
Another point. A friend︊ of mine has digital nomad visa. An agency helped him to get it almost a︋ year ago and now they sent a notice saying something like:
"Some our clients who︌ got the permit a year ago received letters from tax authorities warning that mandatory social︍ security (RETA) registration was not completed, monthly social security payments obligations not fulfilled and you︎ have 10 days to explain that or we are going to initiate the cancellation of️ residence permit"
So it's not exactly saying of tax residency, just social security (probably specific to digital nomads), but still.
I don't know much regarding the second point (it was friend, not me), but the first one was me personally. I found it very frustrating talking to lawyers to hear "Ah we are not sure, it just happens sometimes". I plan to keep my ties to Spain to absolute minimum, staying at monthly tourist rentals for example.
Cheers.