When you place a firework either on the ground or beside a block and it flies up, if there are at least 2 blocks directly above it while it is flying, the firework(s) go through the blocks and will sometimes glitch out and continuously reappear above the blocks until it explodes. It flies about 8-10 blocks high between each reappearance. it is more likely to happen when multiple fireworks are spawned in the same area at the same time, or one after another. If they don't go completely through the blocks they explode inside them.
Could you attach a video or a gif that shows the issue?