What are 'two way' magnets and how do they work? Thomas & Friends Take-n-Play series connect to each other via something described as 'two way' magnets:

the new models use special 'two-way' magnets

As a parent of an owner of two engines of the said series I can attest that indeed the magnets seem to ignore polarity. They attract each other in any combination and, furthermore, they attract 'classical' magnets both N pole and S pole.
I suspect this is some alloy that is capable of rapidly re-aligning its magnetic domains, but is just speculation. I couldn't find any reference to something called 'two-way' magnets nor anything else describing the behavior I'm seeing.
 A: OK, I found the answer but ya ain't gonna like it :-) .  Learning Curve holds patents on a construct containing a disk magnet between two metal "pole pieces"  .  Quoting: 

One of the problems that exists with the couplers described in Östhall
  and Eichorn et al. is their inability to hold the connection when the
  toy vehicles are climbing ascending track segments or traveling on
  curved track segments. The magnetic couplers of Östhall and Eichorn et
  al. have a tendency to separate from each other due to the increased
  stress on the connections which results from these situations. Another
  problem is that two toy vehicles can be connected in a single
  orientation. ... SUMMARY OF THE INVENTION The present invention
  provides a novel magnetic coupler for joining a first toy vehicle to a
  second toy vehicle. A magnetic coupler includes a first connector and
  a disk-shaped magnet for joining the first toy vehicle to the second
  toy vehicle. The first connector has a substantially frustoconical
  shape. The first connector extends from an end wall of the first toy
  vehicle. The frustoconical connector also has an aperture for
  receiving a fastening element. The aperture is countersunk so that the
  head of the fastening element is flush with the frustoconical
  connector. The fastening element is used to mount the disk-shaped
  magnet on the frustoconical connector. The disk-shaped magnet also has
  a fastener opening for receiving the fastener. The disk-shaped magnet
  is oriented so that is perpendicular to the end wall of the first
  vehicle. Other advantages and aspects of the present invention will
  become apparent upon reading the following description of the drawings
  and detailed description of the invention.

The drawings are available here
FWIW,  my original guess (polarity perpendicular to direction of travel) was not that far off. :-)
