You are confusing force with energy. Energy is force x distance.
You are adding energy to a system when you slide one magnet (the one in your hand) along the table, forcing it closer to the other magnet. By doing this you are forcing the system (the two magnets) into a higher energy state. Every system (at least everyone I can think of) seeks a lower energy state. At some point in your slide, the forces build up until the magnet not in your hand breaks free of static friction and slides to a lower energy state (away from the magnet in your hand. The energy expended to move that magnet is the energy YOU stored in the system by forcing the one magnet near to the other.
Another way to think of it is in terms of potential energy. The erarth's gravitational field is not energy, BUT you can store potenial energy in a system by raising a weight to ahigher elevation within that force (gravitational) field. The energy is then reclaimed from the system when the weight drops. With magnets the story is the same, except that the potential energy is due to position in a magnetic field rather than in a gravitational one.
I could go into detail about how dipoles in a ferromagnetic material add up to create a magnetic field, or how you can create a magnetic field with no magnetic magnet at all; but I don't think that is what you are asking. Let me know if i missed the mark.