How old was the snake? Sometime this happens (more likely, the younger the snake) due to abnormal malformations that you (or the breeder) cannot see or predict.
In other words, it just happens sometimes. Just like with humans...a small percentage are born with things like a hole in their heart, etc. Nothing you can do about it,
no way to predict it, & that's partly* why snakes are mostly sold more cheaply as hatchlings...some just may fail to thrive. (*also because older snakes have more time
& food & care invested in them, & their eventual characteristics are more obvious & stabilized) In all likelihood, there was nothing you did wrong...so sorry for your loss.
You might or might not have gotten an answer as to what caused his death if you had a necropsy done right away by an experienced vet, but maybe not even then.