First let's re-quote the Hadith:
حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ، قَالَ حَدَّثَنَا أَبُو عَاصِمٍ، قَالَ أَخْبَرَنَا ابْنُ جُرَيْجٍ، قَالَ أَخْبَرَنِي عَطَاءٌ، قَالَ سَمِعْتُ جَابِرَ بْنَ عَبْدِ اللَّهِ، قَالَ قَالَ النَّبِيُّ صلى الله عليه وسلم " مَنْ أَكَلَ مِنْ هَذِهِ الشَّجَرَةِ ـ يُرِيدُ الثُّومَ ـ فَلاَ يَغْشَانَا فِي مَسَاجِدِنَا ". قُلْتُ مَا يَعْنِي بِهِ قَالَ مَا أُرَاهُ يَعْنِي إِلاَّ نِيئَهُ. وَقَالَ مَخْلَدُ بْنُ يَزِيدَ عَنِ ابْنِ جُرَيْجٍ إِلاَّ نَتْنَهُ.
Narrated 'Ata':
I heard Jabir bin 'Abdullah saying, "The Prophet (ﷺ) said, 'Whoever eats (from) this plant (he meant garlic) should keep away from our mosque." I said, "What does he mean by that?" He replied, "I think he means only raw garlic."
[Sahih Bukhari]
So the hadith states that the Prophet told us not to go to Masjids if we eat gralic. Then the narrator explains that the Prophet only meant the raw gralic. To further understand the Hadith let's see other Hadiths about the same topic:
وَحَدَّثَنِي مُحَمَّدُ بْنُ حَاتِمٍ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ، عَنِ ابْنِ جُرَيْجٍ، قَالَ أَخْبَرَنِي عَطَاءٌ، عَنْ جَابِرِ بْنِ عَبْدِ اللَّهِ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ " مَنْ أَكَلَ مِنْ هَذِهِ الْبَقْلَةِ الثُّومِ - وَقَالَ مَرَّةً مَنْ أَكَلَ الْبَصَلَ وَالثُّومَ وَالْكُرَّاثَ - فَلاَ يَقْرَبَنَّ مَسْجِدَنَا فَإِنَّ الْمَلاَئِكَةَ تَتَأَذَّى مِمَّا يَتَأَذَّى مِنْهُ بَنُو آدَمَ " .
Jabir b. 'Abdullah reported the Messenger of Allah (ﷺ) mying:
He who eats of this (offensive) plant, i. e garlic, and sometirres he said: He who eats onion and garlic and leek, should not approach our mosque for the angels are harmed by the same things as the children of Adam.
[Sahih Muslim]
Here we can see that it's extended to include onion and leak as well, and explanation that these plants have something that harms both Angels and Humans. To figure out what that harmful thing is, let's see the following final hadith:
وعن عمر بن الخطاب رضي الله عنه أنه خطب يوم الجمعة فقال في خطبته: ثم إنكم أيها الناس تأكلون شجرتين ما أراهما إلا خبيثتين: البصل، والثوم -لقد رأيت رسول الله صلى الله عليه وسلم إذا وجد ريحهما من الرجل في المسجد أمر به، فأخرج إلى البقيع، فمن أكلهما، فليمتهما طبخًا. ((رواه مسلم)).
It has been narrated that 'Umar (May Allah be pleased with him) said in the sermon of Friday prayer:
"O you people! You eat garlic and onion. I think the odour of these to be very offensive. I saw that if the Messenger of Allah (ﷺ) happened to find a man with such offensive odour in the mosque, he would order him to be taken out of the mosque and sent to Al-Baqi'. He who wants to eat any of these, should cook them till their odour dies out.
[Muslim]
[Riyad as-Salihin]
So here we are:
First, it's really prohibited, the Prophet told people to go out of Masjid if the ate garlic.
Second, the problem is with the smell (odour), and cooking them well removes that bad smell. And since the prohibition is removed if the reason for prohibition no longer exists, then if you cook garlic (and onion and leek as well) very well so that their smell is gone, you can eat them and come to Masjid since you won't harm people (and angels) with any bad smells.
Hope that's clarifying and helpful, and Allah knows best.