Hola @lloren
Based on the info I found and shared in this thread it is not a good idea to make voluntary contributions to 2 and 3 pillar when resident in Switzerland if your plan is to withdraw the money when resident in Spain.
Based on the info I could find online the withdrawal would be taxable in Spain as earned income. The tax rate depends on your total income and region. For example in Catalunya on income over Eur 175k the rate would be 48%. The more favourable savings income tax would not apply.
@Contemplation talked to a Spanish tax advisor and I believe the conclusion was similar (thread that Dr.Pi referenced above)
It could still make sense to contribute if you have another plan to unlock the money from the system. But probably not worth it for the tax differential on 3 x 7000 CHF
I am not a tax expert, this is not advice