Precisely what your lawyer has said. If the POA ceases to be valid, do not attempt to use it. You will be incurring in severe liabilities if the beneficiaries discover that "half" of the property has been bought by the same person who had faculties to sell. Moreover, if they can prove you knew that the grantor of the POA died, even worst.
I recommend you make an application to the central registry of wills in Madrid to find out if you are contemplated as an inheritor. If not, try to contact those relatives, since they might have the so-called holographic will, which is not registered anywhere and has to be authenticated by a judge. If you cannot find any will and no inheritor, eventually the state will be the last inheritor. Then you will be able to buy that "half" from it.