Changing from male to female is definitely a glitch. If you're playing a ROM or have used any cheats then stuff like that can happen all the time.
However, the HP thing may not be. If Magikarp had 126 and Gyarados as 398 that is perfectly feasible because Gyarados' stats are higher than Magikarps.
Plus you may have got a bunch of EVs in HP which would boost the total - no more than 63 though.