A. If you work in Spain providing legal services without a permanent
establishment (office or similar) you can work for as long as you want
although you would have to pay Spanish taxes on that income. This is
the case provided your work and the income obtained is connected to
Spain. Any other income will be of the interest of the Spanish Inland
Revenue if you spend more than 183 days of any year in Spain. Then you
automatically become a Spanish subject for tax purposes even though
you have not applied for your residence card.
If you have a permanent establishment, then you pay taxes in Spain.
If you decide to become salaried in Spain you will have to obtain your
residence permit and therefore will be taxed in Spain. What many
people do is work without being registered and they stay for as long
as they want without becoming a resident for tax purposes. This is
illegal for the company employing you, although it does happen.
Taxes are paid only in one country. We would need to know the
situation as a whole to know exactly how the double taxation agreement
applies in your case.