People that got sick weren't allowed to take the test unless they fulfilled some checklist someone came up with. People with pneumonia symptoms got turned away at hospital after hospital and instead asked to rest at home which also had an effect on the low number of confirmed cases.
Some articles of people that got confirmed coronavirus but instead of getting quarantined, asked to please not work and self isolate (<- there are also reports of people that were sick for weeks but just continued working with a mask until they were no longer able to). Same for charter flights and people from the cruise. Some people just denied getting tested, so they went home directly.
I have no idea how Japan got away with this but it's true that we are much better off than other countries. The official numbers don't reflect reality a single bit, but I can't argue about the low number of fatalities.