There's no reason at all to interpret the Spanish government's statements on Gibraltar as an attempt to stop Brexit.
There are two things behind the recent comments. One is Spain's agreement with the EU. The other is about how the government looks at home.
1. The EU agreed long ago to the Spanish demand that any economic agreements between the UK and the EU would only include Gibraltar if Spain agreed to Gibraltar being included. The Spanish government is now claiming (sincerely, as far as I know) that this Spanish veto on the inclusion of Gibraltar has not been spelled out clearly in the proposed withdrawal agreement and political declaration. I see no reason at all to think the EU has any intention of going back on its commitment to Spain on this point. Probably the EU negotiators saw no need to spell out this point in this proposed agreement, but I expect the EU negotiators will add a sentence somewhere to mollify the Spanish government.
2. In the last couple of weeks right-wing politicians and newspapers have been giving the Spanish government a hard time over the Gibraltar negotiations. The accusation is that the govt has not taken a hard enough line in its negotiations with the UK. The Spanish right-wing is attacking the govt as a bunch of unpatriotic sell-outs. Some critics say that the Spanish govt should be more demanding in relation to Gibraltar's airport. Some say the negotiations should be about sovereignty, not just co-operation, taxes and the airport. Making a fuss about the current proposed withdrawal agreement gives the Spanish government an opportunity to look good, sticking up for Spain.
Gibraltarians knew back in 2016 that Brexit would be a problem for them. 96% of them, on a high turnout, voted for the UK to remain in the EU. Very soon after the referendum, the Spanish Foreign Minister, José Manuel García-Margallo, was boasting that they would have the Spanish flag flying on the rock sooner than 'the English' thought. Luckily, he was replaced by the much more diplomatic Alfonso Dastis, who (having been the Spanish ambassador to the EU) was very probably the person most involved in the diplomatic coup of getting the EU to promise that Gibraltar could only be included in a future trade deal if Spain agreed.
The new PSOE government's Foreign Minister, Josep Borrell, has been more like Dastis. He's not like García-Margallo. He likes being a plain speaker, calling Brexit a pain in the arse. More importantly, he made it clear he was not trying to negotiate the sovereignty of Gibraltar.
The negotiations are not public, but two topics are known. The Spanish govt proposed that Gibraltar should increase tax, in particular on tobacco, to reduce the incentive to smuggle fags from Gibraltar into Spain. I think it's a very good idea. I don't know what the Gib govt thinks of the idea, but I'd guess they could live with it. Another topic has been the airport, with Spain wanting some sort of joint control over it. I don't know the details of the Spanish demands but I imagine that any surrender of control would be unacceptable to the Gib govt.
I very much hope that there is agreement over Gibraltar and that the relatively civilised Sánchez govt manages to fend off their gung-ho anti-Gibraltarian opponents. There are certainly people on the Spanish side of the negotiations who want agreement.
There are three groups of people whose interests are most at stake.
1. The smugglers. It's tough on them, of course, but I'm all for sacrificing their interests.
2. The Gibraltarians. They need an agreement or things could get really bad for them.
3. Many thousands of Spanish workers who go into Gibraltar every day to earn a living.