There are two parts to the process of making jams, marmalades (and the like) shelf stable for extended periods:
The first part is the recipe - It must contain the correct combination of fruit, sugar, acid and pectin. (If the sugar ratio is not correct it may lead to mold or yeast growth.)
The second part is the canning - Using sanitized canning jars and lids, filling the jars to the recommended level (usually 1/4" from top) then processing in a boiling water canner for the recommended time for your altitude and checking the lids afterward to make sure they sealed properly.
In the case of your recipe, there was not enough sugar and no added acid. This probably would have kept for a while in the refrigerator, but not long term. Filling a jar and putting on an airtight lid does not make your jam shelf stable, there is still air in the jar along with microscopic microbes that can cause mold and illness. Proper canning will remove the air, creating a vacuum seal that can last for many years.
All that being said, I hope you are not discouraged by the above answer. Jam making and canning are not difficult, with a few proper tools and a good resource to learn the proper steps involved, you can be making all kinds of preserves that can last in your pantry for a year (or more).
To get started please check out this link National Center for Home Food Preservation - Apricot Jam. The website has tons of information on how to get started. Freshpreserving.com/canning-101 is also a good resource, but they do promote their own products.