The way it is supposed to work is that from each of the 4 categories, all stimuli will be displayed once before any stimulus would be displayed again. In other words, we choose each stimulus randomly from the category, and we cannot select it again until all the other stimuli in that category are selected. So, it should never happen that, throughout the task, stimulus A of category X would appear n times, and stimulus B of category X would appear n+2 times. n+1 could happen, if the number of trials of each category, throughout the task, is not the product of the number of stimuli for that category and another whole number.
In our example code, we have six stimuli in the two categories and eight stimuli in the two attributes. So, in Block 1 (20 trials -- 10 for each category), within each category, 4 stimuli are supposed to appear twice and 2 stimuli are supposed to appear once. In Block 2
(20 trials -- 10 for each attribute), within each attribute group, 6 stimuli will appear once and 2 stimuli will appear twice. In Block 3 (20 trials) + Block 4 (40 trials), each category will appear, in total, 15 times. In 15 times, all the stimuli must appear at least once.
If you are certain that this is not the case, please send me the data (csv files), and I'll have a look to see that indeed that is the case, and find the reason for that.