Does a compass behaves as it does because the moon acts as a giant magnet?

No, the earth is itself a huge magnet.