This is because it's evolution, Marill, has a different gender ratio to Azurill.
Azurill has a 75%-25% gender ratio in favour of female, however Marill gets a normal 50%-50% gender ratio. So when it evolves, it has a 33% (one in three) chance that it will change from Male to Female when it evolves.
Strangely, they haven't changed this error in any of the recent generations, possibly hinting this was meant to happen.
Hope I helped. :)
Source: Serebii