"I am afraid your grades were almost derailed by a mutant algorithm and I know how stressful that must have been," he told pupils at a school.
An algorithm - a maths calculation - was initially used to determine A-level and GCSE results this year but it was scrapped after problems emerged.
The top civil servant at the Department for Education has also now been sacked.
Jonathan Slater was due to stand down next year, but will now leave the department by next week.
Mr Johnson made his comments about the algorithm during a visit to a secondary school in Coalville, Leicestershire, on Wednesday.
The National Education Union (NEU) called Mr Johnson's comments "brazen" and accused him of trying to "idly shrug away a disaster that his own government created".
The prime minister had previously defended the controversial exam results as a "robust set of grades". His government later made a U-turn following anger over the algorithm and decided to use predicted grades from teachers instead.
Speaking to pupils earlier, Mr Johnson empathised with the problems young people had faced with their exam grades but said he was "very, very glad that it has finally been sorted out".
The prime minister said education was the "great liberator" and the biggest risk for young people was not Covid-19 - but was "continuing to be out of school".
Mr Johnson told pupils they needed to be in school to think about ideas and questions - such as "Is Harry Potter sexist? The answer is no, by the way."
But the remarks on exam problems angered the biggest teachers' union, who saw it as evading responsibility.
Kevin Courtney, joint leader of the NEU, said parents and teachers would be "horrified to see the leader of this country treat his own exams fiasco like some minor passing fad".
"It is certain to put a long-lasting dent in the government's reputation on education."
The exam chaos has also led to the Boris Johnson removing the most senior civil servant at the Department for Education, permanent secretary Jonathan Slater.
A statement said "the prime minister has concluded that there is a need for fresh official leadership" at the department.
The role as the department's most senior civil servant will be taken on in an interim basis by Susan Acland-Hood.
It follows the resignation of Sally Collier as head of the Ofqual exam watchdog for England.
So what does the departure of Jonathan Slater mean - and why does it matter?
For his union, the FDA - and for Labour - it is straightforwardly a sign that, when things go wrong, the buck now firmly stops with the officials and not government ministers.
Angry Conservative MPs were being privately reassured that "heads would roll" after the exams controversy - and both a senior civil servant, and the head of Ofqual, have now departed while Gavin Williamson and his education ministers remain in post.
But something of a pattern is emerging.
In February the most senior official at the Home Office resigned - and took the government to court claiming there had been a "vicious and orchestrated campaign" against him.
Other senior civil servants have made less of a fuss but have nonetheless left their jobs: the most senior Whitehall mandarin - Sir Mark Sedwill - recently moved; the head of the Foreign Office announced an earlier than expected departure; and it was announced last month that the permanent secretary at the Ministry of Justice would be leaving, too.
Cabinet office minister Michael Gove has talked about reforming the civil service - in a speech in June, he said government departments recruited in their own image and their assumptions were "inescapably metropolitan". So a strategic rethink and an increased turnover of senior Whitehall personnel are probably not entirely unrelated.
But what might worry senior civil servants more is that they might be sacrificed for short term news management, rather than as the result of a strategic master plan.
And there is a risk this, in turn, might affect the quality of those who apply for senior civil service roles.
Both departures followed the high-profile problems caused by replacement grades for A-levels, GCSEs and vocational qualifications for exams cancelled in the pandemic.
This focused on an "algorithm" which was accused of producing unfair results - which after a U-turn was replaced by teachers' estimated grades.
Geoff Barton, leader of the ASCL head teachers' union, said: "It is abundantly clear that things have not gone well at the Department for Education and Ofqual, culminating in the debacle over this year's GCSE and A-level grades.
"But it is pretty unsavoury that civil servants appear to be carrying the can while ministers remain unscathed."
Labour's shadow education secretary Kate Green said: "Parents will be looking on in dismay at a government in complete chaos just a matter of days before children will return to schools."
If you’re not a risk taker, you should get the hell out of business.