Planets made out of water
It sounds like you're trying to build a planet out of water.
Water produces gravity the same way rocks do. Regolith is about 2 times as dense as water so an Earth-sized planet will have 1/2 the gravitational pull of the Earth. There's no need for magnets at all. If you just put enough water in the same place, at a low enough temperature, you'll create an Earth-sized ball of water that'll stick together due to gravity. You can do that with (a lot of) ordinary spaceships.
Will this water evaporate into space? Yes, and that's okay.
The Earth loses air (including water vapor) to evaporation all the time. Eventually, all of our gasses & liquid water water will evaporate away. We already lost most of our hydrogen and helium this way. Nitrogen, oxygen, carbon dioxide and water are heavier than hydrogen and helium, so it takes longer for them to evaporate. That's why our atmosphere is made of nitrogen, oxygen, carbon dioxide and water vapor.
The stronger a planet's gravitational field is, the slower its atmosphere will evaporate. The weaker a planet's gravitational field, the faster its atmosphere will evaporate. A planet with 1/2 the Earth's gravitational field will keep its water for a very long time, almost as long as Earth's will. Even a planet with 1/10 of the Earth's gravitational field will keep its water for a long time--at least by human timescales.
How much gravity do you want? The more gravity you want, the more water you should put in the same place and the longer (due to gravity and having more water to begin with) it'll take to evaporate. The colder the planet, the longer it'll take to evaporate too.
Electrostatics
Magnets tend to be really weak because attractive force of magnets decreases at the cube of the distance between magnets. The most powerful tiny magnets we have are protons, neutrons and electrons. Their force is a rounding error compared to the electrostatic effect. (Magnetism basically is just an artifact of electrostatic forces when you mix them with special relativity.)
Usually you have to look very closely at atomic spectra even to see the magnetic effect of protons and neutrons, compared to electrostatics. The only way to get a powerful magnet is by running current through a wire (usually a superconductor) very fast. This would take a lot of handwavium to accomplish en-masse at a small scale. In addition, that many nanomachines changing the properties of water on a water-based planet could really mess up water-based biology, which depends on water behaving like water.
The attractive force of gravity and electric forces decreases at the square of the distance. Gravitic and electric forces will thus be much more effective at holding your planet together. If you filled water with positive and negative much-more-powerful electric charges, called ions, they would hold your water together better than magnets to reduce evaporation. This way you could have a smaller planet with lower gravity yet the same evaporation rate.
Positive and negative ions dissolved in water are called salt. When you dissolve salt in water, the positive and negative ions separate and stick to positive and negative ends of the water molecules. This holds the water together much more strongly than magnets could.
Magnetic shielding
For the sake of completeness, there's one case where magnetism makes sense to protect a water planet. A planet with a north and south magnetic pole gains some protection from the solar wind, a blast of positive and negative particles emitted from the sun which can knock air molecules away from a planet. However, gravity is a far more important factor in this sort of thing.
A few things to note
- The water in the middle of a big enough ball will freeze due to pressure.
- A planet-sized ball of water will heat up during assembly for the same reason meteors heat up when they hit the Earth. (Release of gravitational potential energy.) It'll take some time to cool off.
- Electromagnets work by reducing the effect of one half of a positive-negative electrostatic pair. In this sense, the most powerful magnets are just a weak, inefficient, roundabout way of producing electrostatic forces. You'll get better results by using electric charges directly.
- Water remains at a liquid state when it's at an appropriate pressure and temperature. If you want to preserve Earth-like temperatures then you also have to preserve Earth-like pressures. Pressure is the weight of all the air above you. Decreasing the gravity of a planet reduces the weight of the air, so you'll have to add air to compensate. Thus, a low-gravity water planet will require a thicker atmosphere than Earth's. (Though much of this atmosphere may consist of water vapor, depending on the temperature, pressure and gravity, as well as what other elements are present in the atmosphere.)