Unfortunately in Spain, debts follow the property, not the owner. If there are any outstanding bills then the new owners take on those bills.
Your solicitor should have made sure there were no outstanding debts or kept sufficient funds from the sale to cover them. I have seen several owners get hit for community fees as the sellers should get a letter from the administrators to show there are no outstanding debts. This is also the responsibility of the solicitor to ensure this letter is produced. Same with any outstanding utility bills.
When you take on ownership you also take on all the existing debts from the previous owner. This is why it is important to use the services of a good solicitor.
The above also applies to car ownership as well, always make sure there are no outstanding debts or fines.