Let’s assume Person A gets a patent grant for their invention and starts producing and selling a product based on that invention. After the patent opposition period Person B sues Person A for infringing on their patent, which has been granted way before Person As’ patent was granted. Both patents describe the same invention. Who is liable at that point, the patent office that falsely granted the patent or the person seeking a patent grant? Who keeps the monopoly right for the invention? Were there cases like the one described?
This scenario is rare as examiners are pretty thorough at reviewing their own country’s patents. More likely is that the second patent is a refinement of the first.
The important thing to remember is that a patent doesn’t guarantee you freedom to operate. If there is an existing patent on your device, it precludes you from using your device without a license.