UK Prime Minister Boris Johnson visited both countries to sign the deals, amid debate about them joining Nato.
The pacts also state that Finland and Sweden would assist the UK in a crisis.
Mr Johnson and Swedish PM Magdalena Andersson said co-operation was “even more important” given Russia’s invasion of Ukraine.
The second deal was announced in a joint press conference with Finnish President Sauli Niinistö.
Mr Johnson said the “solemn declaration” between the UK and Finland was reflective of the “extreme difficulty of the times we are in”.
He emphasised the deal was “not a short-term stop gap” while Finland considered whether to join the Nato defensive alliance, but rather a “enduring assurance between two nations”.
Asked if there would be “British boots on the ground” in Finland should a conflict break out, Mr Johnson said military assistance would be offered, but that the “nature of that assistance” would depend upon the “request of the other party”.
Mr Johnson added the agreement would become the “foundation of an intensification of our security and our defence relationship in other ways as well”.
Mr Niinistö said his nation appreciated the UK’s “strong support” of Nato’s open-door policy to Finland’s potential membership.
He said joining Nato would not be “against anybody” and the UK deal was intended to “maximise our security one way or another” while considering joining the defensive alliance.
However, when asked if the possible move could provoke President Vladimir Putin, Mr Niinistö said Russia would be responsible if Sweden or Finland joined Nato.
He said Russia was suggesting the two nations did not have their “own will” by threatening them against applying for membership.
“They are ready to attack their neighbouring country, so… my response would be that ‘you caused this – look at the mirror'”.
Speaking earlier in Sweden Mr Johnson said: “If Sweden were attacked and looked to us for help and support, then we would provide it.”
Asked by the BBC to spell out exactly what the UK would do if Russia attacked Sweden, Mr Johnson said the deal meant that “upon request from the other party, we would come to the other party’s assistance”.
Ms Andersson argued her country would be safer as a result of the mutual assistance agreement with the UK, adding: “Of course this means something. This is important whatever policy choice we make in Sweden.”
She also explained the country was “exploring all possible options and Nato is one of them that is on the table”.
Finland says applying to join Nato is all about defence. But Vladimir Putin doesn’t see it that way. He’s always viewed Nato’s eastern expansion as a threat.
Finland shares an 800 mile (1300km) long border with Russia, bringing the alliance’s military might that much closer Moscow.
Finnish and Swedish membership will make Nato more robust too – boosting its eastern flank and presence in the Baltic Sea. And the Kremlin has threatened retaliation.
Some fear it might deploy targeted nuclear weapons. But Finnish diplomats I’ve spoken to believe Russia has its military hands full in Ukraine and that it will instead focus on cyber and disinformation campaigns.
They say President Putin has himself to blame for Nato expanding. Before Russia invaded Ukraine, most Finns and Swedes preferred to work alongside, but not inside, Nato.
Russia’s aggression – its expansionist zeal – changed all that.
The agreements with Sweden and Finland are not a legal or automatic security guarantee but a political declaration that the UK would come to their aid, if requested.
In an interview with the UnewsUK, Mr Johnson described the deal with Sweden as stating something that “should be implicit” in the countries’ relationship anyway.
Asked if he thought Sweden should join Nato, Mr Johnson said it was “not for the UK to intervene” in their internal debate over whether to apply to become a member of the alliance.
But he added: “We would strongly support Sweden’s accession, if that’s what the Swedes chose to do. We’d certainly try to make things go smoothly and easily as possible.”
Nato – the North Atlantic Treaty Organisation – is a 30-nation defensive alliance founded shortly after the end of World War Two.
It has its headquarters in Brussels, but is dominated by the massive military and nuclear missile power of the US.
Support for joining the Nato has increased in both Sweden and Finland since Russia invaded Ukraine, despite their long history of pursuing policies of military neutrality to avoid conflict with regional powers.
Finland and Sweden are both modern, democratic countries that fulfil the criteria for membership.
Nato’s chief, secretary general Jens Stoltenberg, has said the alliance would welcome them with open arms and there would be minimum delay in processing their membership.
Russia has previously warned both nations not to join Nato and threatened “a military technical response” if they do try to become members.
Kremlin spokesman Dmitry Peskov stressed that Moscow would have to “rebalance the situation” with its own measures if any bid went ahead.