As Cooper said, there's no way to know why such a young dragon passed away, it could have been improper husbandry such as lighting, temps, diet, etc., it could have been either loose substrate, or it could have been a congenital issue or illness/infection that had nothing to do with anything in his habitat or diet. The only way to know for sure is to have a necropsy done by a Reptile Vet, just like when a person dies suddenly for an unknown reason.
I'm very sorry you lost your dragon, that's never easy and I feel for you. What I will say just for your future reference if you happen to get another dragon is that it is not worth using ANY loose substrate in a Bearded Dragon's enclosure or tank, it's unnatural, as they come from the Australian Desert which is hard, rocky terrain, not sandy at all, they lick everything as almost a sense of touch and they always ingest little bits of the loose substrate all day long, every day, whether you see them do it or not, and more importantly and something that owners who use loose substrates never think about, Dragons are prone to Respiratory Infections, Skin/Scale Infections, and eye infections, and ANY loose substrate is an instant breeding ground for all types of bacteria, fungi, parasites, etc. So no matter how often you change out the loose substrate, they are constantly breathing-in and walking around in microbes that are harmful to them. This is how a lot of cases of Yellow Fungus and other fungal infections get started, along with a ton of Upper Respiratory Infections. And I don't know what you mean by "soil", but again, no loose substrate is appropriate, and more importantly it's just not worth the risks and not natural, so if the only reason you use them is because you like how they look, then it's just not worth it. Solid substrates such as tiles, carpet, non-adhesive shelf liner, or even just paper towels or newspaper are so much easier, safer, and the tiles also hold heat and keep their toenails trim, plus you can just spot-clean them with vinegar/water.
That all being said, I am sorry you lost your dragon, and I suggest getting a necropsy done if it will help you get some closure...