Here's why:
* Like poles repel: Magnets have two poles, north and south. Like poles (north-north or south-south) always repel each other.
* Opposite poles attract: Opposite poles (north-south) always attract each other.
Since the north pole of your bar magnet is being repelled, the unmarked magnet must have a north pole facing it to cause this repulsion.