Lots of reasons this could be happening, but it almost always comes down to a poor fit between the nipple and the cap: the cap does not fit all the way down on the nipple, so the explosive material is not in contact with the top of the nipple. When the hammer strikes the cap it does not drive the material against the nipple, so there is essentially no impact imparted to it - thus no ignition. If the second or third attempt is successful then this is likely the case. The first or second strike drove the cap into place so the next strike works.
You could:
a) get smaller diameter nipples (hard to do - almost all replacement nipples these days are sized for No. 11 caps)
b) get larger caps (down side is they might be too large and thus fit loosely - need to be pinched on nipple)
c) get a stronger hammer mainspring (may not be one available) or install a wedge to increase mainspring force (requires gun disassembly/assembly and fabrication of a wedge)
It's also possible that the hammer throw is not long enough for it to actually strike the cap. If the failure to fire occurs several times in a row on the same nipple this is likely the case. Back the nipples out a turn or two and try again - if it works, buy longer nipples or put spacers/washers under the nipple seats.