Because Azurill's gender ratio does not match that of its evolved forms and its evolution is not dependent on gender, being female 75% of the time while Marill and Azumarill are female only 50% of the time, female Azurill had a one in three chance of evolving into a male Marill prior to Generation VI. Whether or not this will happen is determined by its personality value. Azurill is the only Pokémon to do this.
The above is from Bulbapedia, and this is something that can happen. That said, I should probably look into and remedy this as in 6th gen it no longer occurs.