The longer idiom is more of the form "only to [verb] again." The idea of the phrase is that the preceding action occurred with no real effect on the situation, so that the events it described simply repeated instead of a more sensible consequence resulting.
It's used when an event recurs in an unintended, if predictable way. There is often, but not always, an air of frustration or negativity about the sentence. "Again" can be replaced by a number of words describing repeated action.
After kicking the table in the dark I needed to bandage my foot. While walking back to my bedroom I crossed through the kitchen, only to kick the table again.
The dog raced across the lawn with a stick far too large for it to carry. It fell, got up, then ran, only to trip a second time.
I called customer service two hours ago. I keep getting through to an actual person only to be put on hold again when they decide that I need to speak to someone in another department.
The lovers separated for a moment, only to embrace and begin kissing anew a moment later.