You probably can best visualise the way this works if you can get hold of some iron filings and scatter them lightly on a piece of paper or a sheet of glass. When you bring any combination of magnets underneath the sheet the filings will arrange themselves in ways that reveal the patterns of magnetic field.
What has happened is that some of the arrangements that you describe have forced multiple North Poles together with South Poles in between, and the opposite poles have been attracting each other. This may be difficult for you to visualise, but it will become clearer if you see how the filings arrange themselves.