How do I prevent mold growth in homemade chili-infused olive oil? Twice I have tried do this but both times I ended up with mold in the bottle. What am I doing wrong?

I use dark glass bottles (originally for wine) that I sterilize by putting them in the oven at 250 °C for an hour or so. I then put in some regular red chilies (I have washed them with water and then let them dry while the bottle is in the oven) and added extra virgin olive oil.

I finally left the mixture in a cupboard for a couple of weeks.

One thing I have noticed is that the chilies are supposed to sink after a while, but most (all?) of my chilies have stayed afloat. Furthermore, in several photos in the linked search, the seeds of the chilies are "out of" their fruits. How do you accomplish that?
You should make small slits in the chilies so they fill will oil, or just cut them in half.. This will enable them to sink. If the Chilies (or anything you are preserving in oil) stays above the surface you will get mold or worse. It's also a better idea to store in the refrigerator.