Melanocytes are cells that provide pigment/coloration to our skin and hair in the upper layer of our skin. A mole (or nevus, if we’re getting fancy) is actually considered a “benign tumor” of those melanocytes. ‘Tumor’ just means an abnormal, excessive growth of cells (not cancer), so essentially, some of your melanocytes had some funky things happen with their DNA (damage, random mutation, etc.) that caused them to grow more in clusters as opposed to spreading out across your skin.
The reason why you’re told to check the size, borders, color, etc. of moles is that benign moles and potential melanomas can look very different.