This has much to do with convention :
When we talk of electric dipole its potential energy in an electric field is given as $U = -p.E$ here $p$ is dipole moment and $E$ is applied electric field. And when we talk of potential energy of magnet in magnetic field it is given as $U = -m.B$ here $m$ is magnetic moment and $B$ is applied magnetic field.
As you can see from above direction when angle between dipole and field is zero, potential energy is minimum in both cases.
Now let's see the conventions :
1. An electric field goes from positive towards negative while electric dipole is defined to be from negative to positive.
2. A magnetic field goes from north pole to south pole outside magnet and south to north inside, and a magentic moment is also defined to go from north to south outside of its body and south to north inside of its body.
Clearly if we had defined both of the dipoles to be just as the same we define their fields they would both align with their respective fields one would be in stable equilibrium while other will be in unstable equilibrium. So according to convention we make both of the equilibriums stable and assign the dipole moment on its basis.
It is also notworthy that an electric dipole reduces field along its length only between its 2 ends and increases the field outside of its own length. Where on the other hand, a magnetic dipole increases the magnetic field along its length only within its own body and decreases the field outside of its body.