The pieces do not need to know which end should be a $+$ or a $-$ pole, the internal distribution of the dipoles is frozen at manufacture in the permanent magnet. What is actually frozen in are the walls, the boundaries, within which the elementary dipoles are all aligned naturally. Normally, within a single crystal there are several domains separated by walls, and within each one of these several domains the elementary dipoles of the constituent atoms are aligned.
When a soft magnet is unbiased the walls within a domain are positioned naturally so that the effective polarization of the whole crystal zero. An external bias field, unless it is exceptionally strong, cannot change the direction of these aligned dipoles within a domain, there are preferred crystalline direction for the dipole alignments, but it can move the walls between them so that effective polarization of a domain is mostly along the external bias field.
In a hard magnet the walls move with great difficulty, ie., "friction", but can be unfrozen at a temperature above the so-called Curie point at which the ferromagnet becomes a paramagnet. When placed in a bias field to align the dipoles and then cooled below the Curie temperature the walls of the evolving domains will be frozen so that the magnet becomes a permanent one. Every macroscopic piece of the magnet this way is aligned with the original bias field with which it was created. When you break a big magnet into smaller but macroscopic pieces they all present themselves as similarly polarized but smaller permanent magnets.