A has 1st and Goal from B's 5. Obviously, the chain is not set. Through a series of penalties, sacks or whatever, A suddenly has 3rd and Goal from B's 30.
On 3rd down, we have an incomplete pass but B is called for Roughing the Passer. A now has an automatic first down on B 15.
With A's first down on B15, I'm reasonably sure the chain would now have to be set and A would have a 1st and 10 rather than a 1st and Goal. Sitting at a game earlier this year, I had someone (someone who generally seemed pretty knowledgeable) explain that once a team has a 1st and Goal, it can't revert back to a 1st and 10 without either a score or a change of possession. He says A gets the automatic first down, but the chain still doesn't get set and it's 1st and Goal. Those weren't his exact words, but that's the gist of the argument.