This could depend on a lot of things.
For example, if your
<aura:iteration> is looping over data that you're retrieving via an Apex controller, then the first time it is rendered there will be no components because it hasn't got the data from the server yet. One of the later renderings will include the data.
As a general rule, you would be better advised to use
component.find('myAuraId') instead of
document.getElementsByClassName(""). The framework prefers you to access things via component rather than mess around with the DOM directly. Messing with the DOM can lead you into strange difficulties as Locker Service stops you from doing things you might outside of Lightning. So, better to just go with the grain and use
aura:id does not have to be unique and
component.find('myAuraId') will return an array if it matches multiple elements. Annoyingly, if there is only one match, it does not return an array with one component, it just returns a single component. So, to treat it simply, you tend to have to write
var findResults = component.find('myAuraId');
findResults = ;
findResults = [ findResults ];
Once you have a reference to the component, you can call
getElement() if you really must interact directly with the DOM. But, again, I'd strongly advise against it if you can possibly avoid it. If you call
getElement() before the component is rendered, you will get
null. If you call it after, you will get a Locker Service proxy for the element.