The only similarity between magnetism and gravity is that both are forces. Aside from this little similarity, there is a big difference between the two. In a simple term, gravity is usually explained to be a universal force exercised by two bodies onto each other, usually caused by the Earth's rotation. Provided that two objects have mass, the gravitational force will always act on them by pulling them towards each other.
On the other hand, magnetism is a different force entirely. This force is usually created between two objects with certain properties. This force is created when the electrons in each object are aligned so much that they begin to form a kind of attraction between each other.
Magnetism can either cause attraction or repulsion i.e., the force created between two objects can either cause them to be pulled towards each other or cause them to repel each other. All objects with mass are under the influence of gravity, while magnetism can only affect certain objects, especially ferrous objects.