I am not sure whether it was “certain defeat” at the point when they invaded the Falklands. I am not an expert on this, but I believe
1) the UK response to fight back was not a certainty (although it heped then Thatcher to distract from domestic issues at home). But as on the brink said, the UK’s position was close to abandon the islands before the armed conflict started
2) from a military response, the UK did not exactly put a huge armada on its feet. Military victory was then only possible through fortunate circumstances, help from Chile (information, intelligence) and most of all through a total negligence of Argentinian forces on the ground in the Falklands. When they actually held the ground after the invasion, they had all the strategic and military advantages. There was simply inability and inaptitude from the Argentine military that played a major part in this defeat